import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
String str=s.nextLine() ;
ArrayList listStr = new ArrayList();
for (int i =0; i< str.length(); i++)
{
if (listStr.contains(str.charAt(i)))
System.out.println("Repeated Character Found:"+str.charAt(i));
else
listStr.add(str.charAt(i));
}
}
}
input: abbcdeffsah
output:
Repeated Character Found:b
Repeated Character Found:f
Repeated Character Found:a
public class MyClass {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
String str=s.nextLine() ;
ArrayList listStr = new ArrayList();
for (int i =0; i< str.length(); i++)
{
if (listStr.contains(str.charAt(i)))
System.out.println("Repeated Character Found:"+str.charAt(i));
else
listStr.add(str.charAt(i));
}
}
}
input: abbcdeffsah
output:
Repeated Character Found:b
Repeated Character Found:f
Repeated Character Found:a
No comments:
Post a Comment