(String str, int idx, StringBuilder newStr, boolean map[])
| 122 | } |
| 123 | |
| 124 | public static void removeDuplicates(String str, int idx, StringBuilder newStr, boolean map[]) { |
| 125 | if(idx == str.length()) { |
| 126 | System.out.println(newStr); |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | //kaam |
| 131 | char currChar = str.charAt(idx); |
| 132 | if(map[currChar-'a'] == true) { |
| 133 | //duplicate |
| 134 | removeDuplicates(str, idx+1, newStr, map); |
| 135 | } else { |
| 136 | map[currChar-'a'] = true; |
| 137 | removeDuplicates(str, idx+1, newStr.append(currChar), map); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | public static int friendsPairing(int n) { |
| 142 | if(n == 1 || n == 2) { |
nothing calls this directly
no outgoing calls
no test coverage detected