• + 0 comments

    Java

    public static List<Integer> permutationEquation(List<Integer> p) {
            List<Integer> result = new ArrayList<>();
            
            for (int x = 1; x <= p.size(); x++) {
                int px = p.indexOf(x) + 1;
                int py = p.indexOf(px) + 1;
                
                result.add(py);
            }
    
            return result;
        }