Home » Strings(We Suck Every1) » NonRepeated Char

NonRepeated Char


public class NonRepeatedChar {
 public static void main(String[] args) {
 String str = "rajnikanthamitar";
 int[] count = new int[128];

 char[] charArr = str.toLowerCase().toCharArray();

 for (char c : charArr) {
 count[c]++;
 System.out.println("char are "+c);

 }
 for (char c : charArr) {
 if (count[c] == 1) {
 System.out.println("First Non repeated character is : " + c);
 break;
 }
 }



 }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: