You are viewing a single comment's thread. Return to all comments →
In java:
public static int birthday(List s, int d, int m) { // Write your code here
//m --> array lenght //d --> total sum of lenght //s --> array Integer numberOfPossibleCombinations = 0; Integer chocolateBarSize = s.size(); for (int i = 0; i < chocolateBarSize ; i++){ List<Integer> sumList = s.stream().skip(i).limit(m).collect(Collectors.toList()); if(m > sumList.size()){ break; } System.out.print("sumList " + sumList); Integer sum = sumList.stream().mapToInt(Integer::intValue).sum(); System.out.println("sum " + sum); if(sum == d){ numberOfPossibleCombinations++; } } return numberOfPossibleCombinations; }
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 →
In java:
public static int birthday(List s, int d, int m) { // Write your code here