You are viewing a single comment's thread. Return to all comments →
JavaScript
function birthday(s, d, m) { let ways=0; for(let i=0;i<s.length;i++){ if(s.length>1){ let cut_slice=s.slice(i,m); m+=1; let sum_of_cut_slice=0; for(let j=0;j<cut_slice.length;j++){ sum_of_cut_slice+=cut_slice[j]; } if(sum_of_cut_slice==d){ ways+=1; } } else{ if(s[0]==d){ ways+=1; } } } return ways; }
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 →
JavaScript