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.
Java Solutionlittle bit length but easy to understand
publicstaticintbirthday(List<Integer>s,intd,intm){// Write your code hereintres=0;if(s.size()==1&&s.size()==m){if(s.get(0)==d)return1;}for(inti=0;i<s.size();i++){for(intj=i+1;j<s.size();j++){intcount=0;for(intk=i;k<=j;k++){count++;}intsum=0;if(count==m){for(intk=i;k<=j;k++){sum=sum+s.get(k);}if(sum==d)res++;}}}returnres;}
Cookie support is required to access HackerRank
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 →
Java Solution little bit length but easy to understand