You are viewing a single comment's thread. Return to all comments →
I have the same idea as you, but why are most of my test cases failing ?
static int solve(int n, int[] s, int d, int m) { int start=0,end=m-1; int sum=0,num=0; for(int i=start ; i<=end && end<s.length ; i++) { sum+=s[i]; if(i==end) { if(sum == d) { num++; sum=0; i=start+1; start++; end++; } else { sum=0; i=start+1; start++; end++; } } } return num; }
Subarray Division
You are viewing a single comment's thread. Return to all comments →
I have the same idea as you, but why are most of my test cases failing ?