You are viewing a single comment's thread. Return to all comments →
Here is my O(N) c++ solution, you can watch the explanation here : https://youtu.be/D9nfVOmmv7Q
vector<int> permutationEquation(vector<int> p) { vector<int> indexes(p.size() + 1), result; for(int i = 1; i <= p.size(); i++) indexes[p[i-1]] = i; for(int i = 1; i <= p.size(); i++) result.push_back(indexes[indexes[i]]); return result; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sequence Equation
You are viewing a single comment's thread. Return to all comments →
Here is my O(N) c++ solution, you can watch the explanation here : https://youtu.be/D9nfVOmmv7Q