-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_duplicate.java
More file actions
47 lines (35 loc) · 1.05 KB
/
remove_duplicate.java
File metadata and controls
47 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
public class remove_duplicate {
public static void st(String s ,int i,StringBuilder n,boolean a[]){
if(i==s.length()){
System.out.println(n);
return;
}
char c=s.charAt(i);
if(a[c-'a']==true){
st(s,i+1,n,a);
}
else{
a[c-'a']=true;
st(s,i+1,n.append(c),a);
}
}
public static void main(String args[]){
String s="appnnacollege";
st(s,0,new StringBuilder(""),new boolean[26]);
// System.out.println(st(s));
//System.out.println(s.length());
// String ns="";
// for(int i=0;i<s.length();i++){
// int temp=0;
// for(int j=i-1;j>=0;j--){
// if(s.charAt(i)==s.charAt(j)){
// temp=1;
// }
// }
// if(temp==0){
// ns=ns+s.charAt(i);
// }
// }
// System.out.println("string is "+ns);
}
}