MCPcopy Create free account
hub / github.com/apna-college/Alpha / removeDuplicates

Method removeDuplicates

7_RecursionBasics/RecursionBasics.java:124–139  ·  view source on GitHub ↗
(String str, int idx, StringBuilder newStr, boolean map[])

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected