You are viewing a single comment's thread. Return to all comments →
Sliding window Technique | Java
public static int birthday(List<Integer> s, int d, int m) { if(m==1){ return s.contains(d)?1:0; } int start = 0; int end = m; int count = 0; while(start <= s.size()-m){ int sum = 0; for(int i=start;i<end;i++){ sum += s.get(i); } if(sum == d){ count ++ ; } start++; end = start+m; } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Subarray Division
You are viewing a single comment's thread. Return to all comments →
Sliding window Technique | Java