/**
 * @author jagdeepjain
 *
 */
package org.jagdeep.example.algorithm;

public class FirstNonRepeatativeChar {
    public static void getFirstNonRepeatativeChar(String intputString) {
        char[] letters = intputString.toCharArray();
        int count = 0;
        
        for (int i = 0; i < letters.length; i++) {
            count = 0;
            for (int j = 0; j < letters.length; j++) {
                if (letters[i] == letters[j]) {
                    count++;
                }
            }
            if (count == 1) {
                System.out.println("Character '" + letters[i] + "' is the first non repeatative character.");                
                break;
            } 
        }
    }
    
    public static void main(String args[]) {
        getFirstNonRepeatativeChar("abc");
        getFirstNonRepeatativeChar("aabc");
        getFirstNonRepeatativeChar("aabbc");
        getFirstNonRepeatativeChar("aabxfbcc");
    }
}

@@ -247,32 +247,81 @@
  int count = 0;%0A
+        boolean firstNonRepeatativeChar = false;%0A
         %0A       
@@ -727,29 +727,208 @@
     
-break;%0A            %7D 
+firstNonRepeatativeChar = true;%0A                break;%0A            %7D %0A        %7D%0A        %0A        if (firstNonRepeatativeChar != true) %7B%0A            System.out.println(%22No repeative character found.%22);
 %0A   
@@ -1166,20 +1166,66 @@
 aabxfbcc%22);%0A
+        getFirstNonRepeatativeChar(%22aabbcc%22);%0A
     %7D%0A%7D%0A

add flag to support for if not repeative char found