Two pointers
Nahida_nora
这个作者很懒,什么都没留下…
展开
-
Leetcode 41. First Missing Positive
Leetcode 41. First Missing Positive 算法: Check if 1 is present in the array. If not, you’re done and 1 is the answer. If nums = [1], the answer is 2. Replace negative numbers, zeros, and numbers larger than n by 1s. 检查1是否存在,不存在返回1。如果1存在,且数组只有一个元素,则返回2。把所有0原创 2020-08-03 03:53:19 · 140 阅读 · 0 评论 -
Leetcode 713. Subarray Product Less Than K
Leetcode 713. Subarray Product Less Than K Input: nums = [10, 5, 2, 6], k = 100 Output: 8 index:0 [10], [10, 5], ans = 2 index: 1 [5], [5,2], [5,2,6], ans = 5 index: 2 [2], [2, 6], ans = 7 index: 3 [6], ans =8 Approach #2: Sliding Window [Accepted] Input:原创 2020-06-23 00:43:48 · 91 阅读 · 0 评论