xinyu04

导航

07 2023 档案

LeetCode 239. Sliding Window Maximum 单调队列
摘要:You are given an array of integers `nums`, there is a sliding window of size `k` which is moving from the very left of the array to the very right. Yo 阅读全文

posted @ 2023-07-28 21:17 Blackzxy 阅读(22) 评论(0) 推荐(0)

LeetCode 438. Find All Anagrams in a String 滑动窗口
摘要:Given two strings `s` and `p`, return an array of all the start indices of `p`'s anagrams in s. You may return the answer in any order. An Anagram is 阅读全文

posted @ 2023-07-23 22:31 Blackzxy 阅读(7) 评论(0) 推荐(0)

LeetCode 3. Longest Substring Without Repeating Characters 滑动窗口
摘要:Given a string `s`, find the length of the longest substring without repeating characters. ## Solution 用一个 $dict$ 来映射字符的次数。然后用 $left$, $right$ 来决定wind 阅读全文

posted @ 2023-07-22 23:51 Blackzxy 阅读(14) 评论(0) 推荐(0)

LeetCode 1201. Ugly Number III 数学+二分答案
摘要:An ugly number is a positive integer that is divisible by $a$, $b$, or $c$. Given four integers $n$, $a$, $b$, and $c$, return the $n$th ugly number. 阅读全文

posted @ 2023-07-19 20:57 Blackzxy 阅读(12) 评论(0) 推荐(0)

LeetCode 875. Koko Eating Bananas 二分答案
摘要:Koko loves to eat bananas. There are $n$ piles of bananas, the $i$th pile has $piles[i]$ bananas. The guards have gone and will come back in `h` hours 阅读全文

posted @ 2023-07-19 19:43 Blackzxy 阅读(18) 评论(0) 推荐(0)

LeetCode 1011. Capacity To Ship Packages Within D Days 二分答案
摘要:A conveyor belt has packages that must be shipped from one port to another within `days` days. The ith package on the conveyor belt has a weight of $w 阅读全文

posted @ 2023-07-19 16:34 Blackzxy 阅读(9) 评论(0) 推荐(0)

LeetCode 852. Peak Index in a Mountain Array 二分
摘要:An array arr a mountain if the following properties hold: * `arr.length` >= 3 * There exists some i with `0 arr[i + 1] > ... > arr[arr.length - 1] ``` 阅读全文

posted @ 2023-07-18 22:31 Blackzxy 阅读(10) 评论(0) 推荐(0)

LeetCode 793. Preimage Size of Factorial Zeroes Function 二分
摘要:Let `f(x)` be the number of zeroes at the end of x!. Recall that $x! = 1 * 2 * 3 * ... * x$ and by convention, 0! = 1. For example,` f(3) = 0` because 阅读全文

posted @ 2023-07-16 23:15 Blackzxy 阅读(7) 评论(0) 推荐(0)

LeetCode 658. Find K Closest Elements 二分+双指针
摘要:Given a sorted integer array `arr`, two integers `k` and `x`, return the `k` closest integers to `x` in the array. The result should also be sorted in 阅读全文

posted @ 2023-07-15 22:45 Blackzxy 阅读(14) 评论(0) 推荐(0)

LeetCode 354. Russian Doll Envelopes 排序+LIS
摘要:You are given a 2D array of integers `envelopes` where `envelopes[i] = [wi, hi]` represents the width and the height of an envelope. One envelope can 阅读全文

posted @ 2023-07-14 22:37 Blackzxy 阅读(10) 评论(0) 推荐(0)

LeetCode 519. Random Flip Matrix 哈希Map
摘要:There is an `m x n` binary grid matrix with all the values set 0 initially. Design an algorithm to randomly pick an index `(i, j)` where `matrix[i][j] 阅读全文

posted @ 2023-07-14 20:58 Blackzxy 阅读(10) 评论(0) 推荐(0)