@@ -0,0 +1,975 @@
+package leetcode;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * https://leetcode.com/problems/first-unique-character-in-a-string/%0A */%0Apublic class Problem387 %7B%0A    public int firstUniqChar(String s) %7B%0A        Map%3CCharacter, Integer%3E charCounts = new HashMap%3C%3E();%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            if (!charCounts.containsKey(s.charAt(i))) %7B%0A                charCounts.put(s.charAt(i), 1);%0A            %7D else %7B%0A                charCounts.put(s.charAt(i), charCounts.get(s.charAt(i)) + 1);%0A            %7D%0A        %7D%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            int count = charCounts.get(s.charAt(i));%0A            if (count == 1) %7B%0A                return i;%0A            %7D%0A        %7D%0A        return -1;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem387 prob = new Problem387();%0A        System.out.println(prob.firstUniqChar(%22leetcode%22));%0A        System.out.println(prob.firstUniqChar(%22loveleetcode%22));%0A    %7D%0A%7D%0A

Solve problem 387