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.
int getWays(vector < int > squares, int d, int m){
int sum = 0;
int index = 0;
int getway = 0;
for(int i = 0; i < squares.size(); i++){
sum += squares[i];
if(m == (i - index + 1)){
if(d == sum){
getway++;
}
sum -= squares[index++];
}
}
return getway;
}
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 →
I hope the below solution is in O(n):
int getWays(vector < int > squares, int d, int m){ int sum = 0; int index = 0; int getway = 0;
}