Skip to content

Commit a39ee6d

Browse files
author
alxkm
committed
refactor: removed redundant class name
1 parent 7bf657e commit a39ee6d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/main/java/com/thealgorithms/strings/PermuteString.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,10 @@ private PermuteString() {
4444
*/
4545
public static Set<String> getPermutations(String str) {
4646
Set<String> permutations = new HashSet<>();
47-
PermuteString.generatePermutations(str, 0, str.length(), permutations);
47+
generatePermutations(str, 0, str.length(), permutations);
4848
return permutations;
4949
}
5050

51-
/**
52-
* Swaps the characters at the specified positions in the given string.
53-
*
54-
* @param str the string in which characters will be swapped
55-
* @param i the position of the first character to swap
56-
* @param j the position of the second character to swap
57-
* @return a new string with the characters at positions i and j swapped
58-
*/
59-
private static String swapCharacters(String str, int i, int j) {
60-
char[] chars = str.toCharArray();
61-
char temp = chars[i];
62-
chars[i] = chars[j];
63-
chars[j] = temp;
64-
return new String(chars);
65-
}
66-
6751
/**
6852
* Generates all permutations of the given string and collects them into a set.
6953
*
@@ -86,4 +70,20 @@ private static void generatePermutations(String str, int start, int end, Set<Str
8670
}
8771
}
8872
}
73+
74+
/**
75+
* Swaps the characters at the specified positions in the given string.
76+
*
77+
* @param str the string in which characters will be swapped
78+
* @param i the position of the first character to swap
79+
* @param j the position of the second character to swap
80+
* @return a new string with the characters at positions i and j swapped
81+
*/
82+
private static String swapCharacters(String str, int i, int j) {
83+
char[] chars = str.toCharArray();
84+
char temp = chars[i];
85+
chars[i] = chars[j];
86+
chars[j] = temp;
87+
return new String(chars);
88+
}
8989
}

0 commit comments

Comments
 (0)