• + 0 comments
    public static List<Integer> permutationEquation(List<Integer> p) {
        Map<Integer, Integer> map = IntStream.
                range(0, p.size()).
                boxed().
                collect(Collectors.toMap(s-> p.get(s), s-> s+1));
        List<Integer> result = IntStream.range(1, p.size()+1).
            boxed().
            map(map::get).
            map(map::get).
            collect(Collectors.toList());
        return result;
    }