Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

Recursively print Permutations of a String

        recursivelyReverse("", "helloWorld");
   
    private static void recursivelyReverse(String first, String second) {
        if (second.length() == 0) {
            System.out.println(first);
            return;
        }
        for (int index = 0; index < second.length(); index++) {
            recursivelyReverse(first + second.charAt(index), second.substring(0, index) + second.substring(index + 1));
        }
    }

No comments:

Post a Comment

Search 24 Bytes

Loading...