You are viewing a single comment's thread. Return to all comments →
What do you think about recursive approach?
int solve(vector<int> s, int d, int m, int i) { if(i < s.size() - m + 1) { int sum = 0; for(int j = i; j < i+m; ++j) sum += s[j]; bool good_choco = sum == d; return good_choco + solve(s, d, m, i+1); } else return 0; }
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 →
What do you think about recursive approach?