Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -13,7 +13,7 @@ Backtracking algorithm used in the program:-
*/
public class PermuteString {
//Function for swapping the characters at position I with character at position j
//Function for swapping the characters at position I with character at position j
public static String swapString(String a, int i, int j) {
char[] b = a.toCharArray();
char ch;
@ -30,18 +30,18 @@ public class PermuteString {
generatePermutation(str, 0, len);
}
//Function for generating different permutations of the string
//Function for generating different permutations of the string
public static void generatePermutation(String str, int start, int end) {
//Prints the permutations
//Prints the permutations
if (start == end - 1) {
System.out.println(str);
} else {
for (int i = start; i < end; i++) {
//Swapping the string by fixing a character
//Swapping the string by fixing a character
str = swapString(str, start, i);
//Recursively calling function generatePermutation() for rest of the characters
//Recursively calling function generatePermutation() for rest of the characters
generatePermutation(str, start + 1, end);
//Backtracking and swapping the characters again.
//Backtracking and swapping the characters again.
str = swapString(str, start, i);
}
}