import java.util.HashSet;

public class Strings {

    static Character findFirstNonRepeated(String s) {
        if(s == null || s.length() == 0) {
            return null;
        }
        if(s.length() == 1) {
            return Character.valueOf(s.charAt(0));
        }
        HashSet<Character> chars = new HashSet<Character>();
        for (int i = 0; i < s.length(); i++) {
            Character character = Character.valueOf(s.charAt(i));
            if(!chars.add(character)) {
                return character;
            }
        }
        return null;
    }


    static String removeChars(String s, String toRemove) {
        if(s == null || s.isEmpty() || toRemove == null || toRemove.isEmpty()) {
            return s;
        }
        StringBuilder sb = new StringBuilder();
        HashSet<Character> del = new HashSet<Character>();
        for (int i = 0; i < toRemove.length(); i++) {
            del.add(Character.valueOf(toRemove.charAt(i)));
        }
        for (int i = 0; i < s.length(); i++) {
            char charAt = s.charAt(i);
            if(!del.contains(Character.valueOf(charAt))) {
                sb.append(charAt);
            }
        }
        return sb.toString();
    }

    static char [] removeChars(char[] s, char[] toRemove) {
        if(s == null || s.length == 0 || toRemove == null || toRemove.length == 0) {
            return s;
        }
        HashSet<Character> del = new HashSet<Character>();
        for (int i = 0; i < toRemove.length; i++) {
            del.add(Character.valueOf(toRemove[i]));
        }
        int curr = 0;
        for (int i = 0; i < s.length; i++) {
            char charAt = s[i];
            if(!del.contains(Character.valueOf(charAt))) {
                s[curr] = charAt;
                curr ++;
            }
        }
        char [] newChars = new char[curr];
        System.arraycopy(s, 0, newChars, 0, curr);
        return newChars;
    }

    public static void main(String[] args) {
        assert findFirstNonRepeated("aaaaaa") .equals( Character.valueOf('a') ): findFirstNonRepeated("aaaaaa");
        assert findFirstNonRepeated("abcdefg") == null : findFirstNonRepeated("abcdefg");
        assert findFirstNonRepeated("abcadefg") .equals( Character.valueOf('a') ) : findFirstNonRepeated("abcadefg");

        assert "".equals(removeChars("aaaaaaaa", "a")) : removeChars("aaaaaaaa", "a");
        assert "b".equals(removeChars("aaabaaaa", "a")) : removeChars("aaabaaaa", "a");
        assert "abc".equals(removeChars("abc", "")) : removeChars("abc", "");
        assert "abc".equals(removeChars("abc", "d")) : removeChars("abc", "d");
        assert "".equals(removeChars("", "d")) : removeChars("", "d");


        assert "".equals(new String(removeChars("aaaaaaaa".toCharArray(), "a".toCharArray()))) : removeChars("aaaaaaaa", "a");
        assert "b".equals(new String(removeChars("aaabaaaa".toCharArray(), "a".toCharArray()))) : removeChars("aaabaaaa", "a");
        assert "abc".equals(new String(removeChars("abc".toCharArray(), "".toCharArray()))) : removeChars("abc", "");
        assert "abc".equals(new String(removeChars("abc".toCharArray(), "d".toCharArray()))) : removeChars("abc", "d");
        assert "".equals(new String(removeChars("".toCharArray(), "d".toCharArray()))) : removeChars("", "d");
    }
}

@@ -1926,24 +1926,918 @@
 ars;%0A    %7D%0A%0A
+    static char %5B%5D reverseWords(char%5B%5D s) %7B%0A        char %5B%5D rev = new char%5Bs.length%5D;%0A        int lastSrcPos = -1;%0A        int currDestPos = 0;%0A        for (int i = s.length - 1; i %3E=0; i--) %7B%0A            char c = s%5Bi%5D;%0A            if(c == ' ' %7C%7C i == 0) %7B%0A                if(lastSrcPos %3E= 0) %7B%0A                    int end = c == ' '? i +1 :i;%0A                    int length = lastSrcPos - end +1;%0A                    System.arraycopy(s, end, rev, currDestPos, length);%0A                    currDestPos += length;%0A                    rev%5BcurrDestPos++%5D = ' ';%0A                    lastSrcPos = -1;%0A                %7D%0A            %7D else if(lastSrcPos %3C 0)%7B%0A                lastSrcPos = i;%0A            %7D%0A        %7D%0A        if(currDestPos %3C rev.length - 1) %7B%0A            for (int i = currDestPos; i %3C rev.length; i++) %7B%0A                rev%5Bi%5D = ' ';%0A            %7D%0A        %7D%0A        return rev;%0A    %7D%0A%0A
     public s
@@ -4196,21 +4196,719 @@
 rs(%22%22, %22d%22);
+%0A%0A        System.out.println(new String(reverseWords(%22%22.toCharArray())));%0A        System.out.println(new String(reverseWords(%22 %22.toCharArray())));%0A        System.out.println(new String(reverseWords(%22a %22.toCharArray())));%0A        System.out.println(new String(reverseWords(%22 a %22.toCharArray())));%0A        System.out.println(new String(reverseWords(%22 a%22.toCharArray())));%0A        System.out.println(new String(reverseWords(%22 ab %22.toCharArray())));%0A        System.out.println(new String(reverseWords(%22 abc def   %22.toCharArray())));%0A        System.out.println(new String(reverseWords(%22'abc def   '%22.toCharArray())));%0A        System.out.println(new String(reverseWords(%22 a b c d e f g%22.toCharArray())));
 %0A    %7D%0A%7D%0A

reverse words