You are viewing a single comment's thread. Return to all comments →
Java 100% O(N):
public static List<Integer> permutationEquation(List<Integer> p) { List<Integer> y = new ArrayList<>(); Map<Integer, Integer> idxToValue = new HashMap<>(); for (int i=1 ; i<=p.size() ; i++) { idxToValue.put(p.get(i-1), i); } for (int i=1 ; i<=p.size() ; i++) { y.add(idxToValue.get(idxToValue.get(i))); } return y; }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Sequence Equation
You are viewing a single comment's thread. Return to all comments →
Java 100% O(N):