public class FirstNonReapeating {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
String str = "rrrrrraaaaavvvvvi";
int[] count = new int[128];
char[] charArr = str.toLowerCase().toCharArray();
for (char c : charArr) {
count[c]++;
}
for (char c : charArr) {
if (count[c] == 1) {
System.out.println("First Non repeated character is : " + c);
break;
}
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
String str = "rrrrrraaaaavvvvvi";
int[] count = new int[128];
char[] charArr = str.toLowerCase().toCharArray();
for (char c : charArr) {
count[c]++;
}
for (char c : charArr) {
if (count[c] == 1) {
System.out.println("First Non repeated character is : " + c);
break;
}
}
}
}
No comments:
Post a Comment