topic:
Given n
The array of a positive integer and a positive integer target
。
Find out the array to satisfy it ≥ target
The smalle Continuous array [numsl, numsl+1, ..., numsr-1, numsr]
,And return its length。If there is no conditional sub -array,return 0
。
Exemplary example 1:
enter:target = 7, nums = [2,3,1,2,4,3]
Output:2
explain:Sub -array [4,3]
是该条件下的Small length array。
Exemplary example 2:
enter:target = 4, nums = [1,4,4] Output:1
Exemplary example 3:
enter:target = 11, nums = [1,1,1,1,1,1,1,1] Output:0
hint:
1 <= target <= 109
1 <= nums.length <= 105
1 <= nums[i] <= 105
Advance:
- If you have achieved it
O(n)
Time complexity solution, Please try to design aO(n log(n))
Time complexity solution。
Related Topics
Thought:
Originally planned to use double pointers,But my double pointer is over time。
Code:
1 | class Solution: |