We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticintbirthday(List<Integer>s,intd,intm){// Write your code here//initialize the variable count to keep track of # of possible ways to divide the chocolateintcount=0;//number of ways to take m adjacent numbers in size s chocolateintcombinations=s.size()-m+1;//for each possible combinationfor(inti=0;i<combinations;i++){intsum=0;for(intj=0;j<m;j++){//sum together m adjacent squaressum+=s.get(i+j);}//increment count if sum equals to birthday dif(sum==d){count++;}}returncount;}
Cookie support is required to access HackerRank
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 solution