Click here to see the full article post
I found that if I changed double to long, then it is accepted........ brute force way!
For this sentence:
Further, for sum_i as the cumulative sum up to the current (i-th) index, all we need is sum_i - sum_j >= 0 such that j - i >= k.
Should it be sum_j - sum_i >= 0? Am I missing something here? Thanks in advance, appreciate the great write up!
@jwgoh You are right. I have corrected it. Thanks.
Why here "we can just consider the minimum cumulative sum upto the index j - i" is "j - i" not "j - k" ?
@xshen93 Thanks for pointing it out. I have corrected the index. min_sum initial value is set to 0 to consider the case where required subarray starts from index 0.
@vinod23 Thanks. I got it.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.