Skip to content

Commit

Permalink
fix minor diff in 2 approaches
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoanh An committed Dec 14, 2019
1 parent 899ecdc commit d45b977
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gtci/avg_subarray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Example:
- Input: []int{1, 3, 2, 6, -1, 4, 1, 8, 2}, k=5
Output: []int{2.2, 2.8, 2.4, 3.6, 2.8}
Approach: Sliding Window
Approach:
- View each contiguous subarray as a sliding window of k elements.
- As we move to the next subarray, slide the window by one element to
reuse the sum from previous array.
Expand Down
4 changes: 2 additions & 2 deletions gtci/max_subarray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Example:
- Input: int{2, 1, 5, 1, 3, 2}, k=3
Output: 9
Explanation: Subarray with maximum sum is [5, 1, 3].
Approach: Sliding Window
Approach:
- View each contiguous subarray as a sliding window of k elements.
- As we move to the next subarray, slide the window by one element to
reuse the sum from previous array.
reuse the sum from previous array and update the maximum sum.
Cost:
- O(n) time, O(1) space.
Expand Down

0 comments on commit d45b977

Please sign in to comment.