package com.fishercoder.solutions;

/**
 * 387. First Unique Character in a String Given a string, find the first non-repeating character in
 * it and return it's index. If it doesn't exist, return -1.
 *
 * Examples:
 *
 * s = "leetcode" return 0.
 *
 * s = "loveleetcode", return 2. Note: You may assume the string contain only lowercase letters.
 */

public class _387 {
  public static class Solution1 {
    public static int firstUniqChar(String s) {
      int[] freq = new int[26];
      for (int i = 0; i < s.length(); i++) {
        freq[s.charAt(i) - 'a']++;
      }
      for (int i = 0; i < s.length(); i++) {
        if (freq[s.charAt(i) - 'a'] == 1) {
          return i;
        }
      }
      return -1;
    }
  }
}

@@ -33,326 +33,8 @@
 s;%0A%0A
-/**%0A * 387. First Unique Character in a String Given a string, find the first non-repeating character in%0A * it and return it's index. If it doesn't exist, return -1.%0A *%0A * Examples:%0A *%0A * s = %22leetcode%22 return 0.%0A *%0A * s = %22loveleetcode%22, return 2. Note: You may assume the string contain only lowercase letters.%0A */%0A%0A
 publ
@@ -51,16 +51,18 @@
 387 %7B%0A  
+ 
+ 
 public s
@@ -85,16 +85,20 @@
 tion1 %7B%0A
+    
     publ
@@ -143,16 +143,22 @@
 %7B%0A      
+ 
+     
 int%5B%5D fr
@@ -175,16 +175,22 @@
 nt%5B26%5D;%0A
+      
       fo
@@ -234,16 +234,24 @@
         
+  
+      
 freq%5Bs.c
@@ -269,24 +269,30 @@
 'a'%5D++;%0A
+      
       %7D%0A
       fo
@@ -279,24 +279,30 @@
           %7D%0A
+      
       for (i
@@ -342,16 +342,24 @@
         
+       
+ 
 if (freq
@@ -382,24 +382,34 @@
 a'%5D == 1) %7B%0A
+          
           re
@@ -428,18 +428,32 @@
     
+ 
-%7D%0A
+       %7D%0A      
       %7D%0A
     
@@ -444,24 +444,30 @@
           %7D%0A
+      
       return
@@ -475,16 +475,22 @@
 -1;%0A    
-%7D%0A
+    %7D%0A  
   %7D%0A%7D%0A

refactor 387