Day2-Array02
209. Minimum Size Subarray Sum
Note:
- sliding window: a fixed or variable-size window is moved through a data structure, to solve problems efficiently based on continous subsets of elements. It’s used to find subarrays or substrings to a given set of conditions
- start index: how to move it?
- increase the start index when meet the condition
- end index: how to move it?
- use for loop to keep increase the end index
- from start to end, what are inside the scope?
Time Complexity && Space Complexity
- Time Complexity: O(n)
- when moving the window, every element is added to sum for one time, is deleted from the sum for one time
- Space Complexity: O(1)
1 | /** |
59. Spiral Matrix II
Note:
- every for loop only include the left, exclude the right, which could keep the consistent
Time Complexity && Space Complexity
- Time Complexity: O(n^2)
- when moving the window, every element is added to sum for one time, is deleted from the sum for one time
- Space Complexity: O(1)
1 | /** |
- Title: Day2-Array02
- Author: Guoyi
- Created at : 2024-08-23 09:35:17
- Updated at : 2024-12-07 03:58:41
- Link: https://guoyiwang.github.io/Algorithm/Day2-Array02/
- License: This work is licensed under CC BY-NC-SA 4.0.
Comments