You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution
string larrysArray(vector<int> A) { if(A.size() == 2 && A[0] > A[1]) return "NO"; else if(A.size() == 1 || A.size() == 0) return "YES"; else { auto min_it = std::min_element(A.begin(), A.end()); int tempIndex = distance(A.begin(), min_it); A.erase(A.begin() + tempIndex); if(tempIndex % 2 != 0){ swap(A[0], A[1]); } return larrysArray(A); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Larry's Array
You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution