package org.xander.katas;

public class TestA {
    public char findFirstUnique(String s) {
        int number = -1;
        if (s.length() == 1) {
            return s.charAt(0);
        }
        for (int i = 0; i < s.length(); i++) {
            if (i == 0
                    && i + 1 < s.length()
                    && s.charAt(i + 1) != s.charAt(i) ) {
                number = i;
                break;
            }
            if (i - 1 >= 0
                    && s.charAt(i - 1) != s.charAt(i)
                    && i + 1 < s.length()
                    && s.charAt(i + 1) != s.charAt(i)) {
                number = i;
                break;
            }
        }
        if (number < 0) {
            throw new IllegalArgumentException("no unique element");
        }
        return s.charAt(number);
    }
}

@@ -44,17 +44,16 @@
 tA %7B%0A   
- 
 public c
@@ -654,32 +654,191 @@
 ;%0A            %7D%0A
+            if (i == s.length() - 1%0A                    && s.charAt(i - 1) != s.charAt(i) ) %7B%0A                number = i;%0A                break;%0A            %7D%0A
         %7D%0A      

find last