public class FirstUnique{
public static void main(String args[]){
new FirstUnique().getUnique("stroirotatous");
}
public void getUnique(String str){
int arr[] = new int[255];
for(int i = 0 ; i<str.length() ; i++)
{
arr[str.charAt(i)]++;
}
for(int j = 0; j<str.length(); j++)
{
if(arr[str.charAt(j)] == 1)
{
System.out.println((char)j);
return;
}
}
}
}
public static void main(String args[]){
new FirstUnique().getUnique("stroirotatous");
}
public void getUnique(String str){
int arr[] = new int[255];
for(int i = 0 ; i<str.length() ; i++)
{
arr[str.charAt(i)]++;
}
for(int j = 0; j<str.length(); j++)
{
if(arr[str.charAt(j)] == 1)
{
System.out.println((char)j);
return;
}
}
}
}
No comments:
Post a Comment