You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'''不懂的可以参考: https://leetcode-cn.com/problems/subarray-sum-equals-k/solution/hot-100-he-wei-kde-zi-shu-zu-python3-cong-bao-li-j/[1:29] StartThought Process1. [Brute Force]for i -> n for j -> (i, n) find sum of nums[i:j + 1] == targetTime: O(N^3)2. PreSumfor i -> n preSum = [0] * len(arr) for j -> (i, n): if preSum[j] - preSum[i] == k add to resTime: O(N^2)3. preSumbecause: preSum[j] - preSum[i] == kso: preSum[i] == preSum[j] - kbecause we always iterate i before jwe store preSum[i] in hashand while we iterate J, we do preSum[j] - k, and see if it's in hash.Time: O(N)'''
560. Subarray Sum Equals K
The text was updated successfully, but these errors were encountered: