0
2 answers
0
import java.io.*;
class RemoveDuplicate
{
public static void main(String[]args )throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a sentence: ");
String str= br.readLine().toLowerCase();
int l = str.length();
char a[] = str.toCharArray();
int i,j,k;
for(i=0;i<l;i++){
for(j=i+1;j<l;j++){
if(a[i]==a[j]){
for(k=j;k<l-1;k++)
a[k] = a[k+1];
l--;
j--;
}
}
}
for(i=0;i<l;i++)
System.out.print(a[i]);
}
}
0
import java.io.*;
public class Duplicate
{
public static void main ()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Input word");
String s=br.readLine();
s.toLowerCase();
int l=s.length();String b="";
String d="";
for(int i=0;i<l;i++)
{
char c=s.charAt(i);
if(b.indexOf(c)==-1)
b+=c;
}
System.out.println(b);
}
}
Log in to your account to answer this questions.