You are viewing a single comment's thread. Return to all comments →
Java 8
public static int birthday(List<Integer> s, int d, int m) { int totalSplits = 0; for(int i = 0; i < s.size(); i++) { int sum = 0; for(int j = m; j > 0 ; j--) { int offset = j - 1; if (i + offset >= s.size()) break; sum += s.get(i + offset); } if (sum == d) { totalSplits++; } } return totalSplits; }
Seems like cookies are disabled on this browser, please enable them to open this website
Subarray Division 1
You are viewing a single comment's thread. Return to all comments →
Java 8