xinyu04

导航

2023年8月8日 #

LeetCode 16. 3Sum Closest 双指针+排序

摘要: Given an integer array `nums` of length n and an integer `target`, find three integers in nums such that the sum is closest to `target`. Return the su 阅读全文

posted @ 2023-08-08 17:18 Blackzxy 阅读(5) 评论(0) 推荐(0) 编辑

2023年7月28日 #

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 阅读(5) 评论(0) 推荐(0) 编辑

2023年7月23日 #

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 阅读(1) 评论(0) 推荐(0) 编辑

2023年7月22日 #

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 阅读(2) 评论(0) 推荐(0) 编辑

2023年7月19日 #

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 阅读(3) 评论(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 阅读(5) 评论(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 阅读(5) 评论(0) 推荐(0) 编辑

2023年7月18日 #

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 阅读(6) 评论(0) 推荐(0) 编辑

2023年7月16日 #

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 阅读(4) 评论(0) 推荐(0) 编辑

2023年7月15日 #

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 阅读(6) 评论(0) 推荐(0) 编辑