@@ -0,0 +1,958 @@
+package coding4fun;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Find the next permutation in lexicographical order.%0A *%0A * %3Cpre%3E%0A * Input : 362541%0A * Output: 364125%0A * %3C/pre%3E%0A */%0Apublic class Problem42 %7B%0A    private static String nextPermutation(String str) %7B%0A        char%5B%5D chars = str.toCharArray();%0A        List%3CCharacter%3E reversed = new ArrayList%3C%3E();%0A        for (int i = chars.length - 1; i %3E= 1; i--) %7B%0A            // in increasing order%0A            if (chars%5Bi + 1%5D %3C chars%5Bi%5D) %7B%0A                for (int j = 0; j %3C reversed.size(); j++) %7B%0A                    // TODO:%0A                %7D%0A            %7D else %7B%0A                reversed.add(chars%5Bi%5D);%0A            %7D%0A        %7D%0A    %7D%0A%0A    private static void swap(char%5B%5D chars, int i, int j) %7B%0A        char tmp = chars%5Bi%5D;%0A        chars%5Bi%5D = chars%5Bj%5D;%0A        chars%5Bj%5D = tmp;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(nextPermutation(%22362541%22));%0A    %7D%0A%7D%0A

Add problem 42