You are viewing a single comment's thread. Return to all comments →
C++ Solution: int pickingNumbers(vector a) {
sort(a.begin(), a.end()); int start = 0; int stop = 1; int res = 0; while(stop < a.size()) { if(abs(a[start] - a[stop]) <= 1) { stop++; } else { res = max(res, stop - start); start = stop; stop++; } } res = max(res, stop - start); return res;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
C++ Solution: int pickingNumbers(vector a) {
}