• + 0 comments

    java 8

    public static List<Integer> permutationEquation(List<Integer> p) {
        // Write your code here
    
        List<Integer> newList = new ArrayList<>();
        int x = 1;
        while (x <= p.size()) {
            for (int i = 0; i < p.size(); i++) {
                if (p.get(i) == x) {
                    newList.add((p.indexOf(i + 1)) + 1);
                }
            }
            x++;
    
        }
        return newList;
    }