java.lang.Object
g0301_0400.s0387_first_unique_character_in_a_string.Solution

public class Solution extends Object
387 - First Unique Character in a String.<p>Easy</p> <p>Given a string <code>s</code>, <em>find the first non-repeating character in it and return its index</em>. If it does not exist, return <code>-1</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;leetcode&rdquo;</p> <p><strong>Output:</strong> 0</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;loveleetcode&rdquo;</p> <p><strong>Output:</strong> 2</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;aabb&rdquo;</p> <p><strong>Output:</strong> -1</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 10<sup>5</sup></code></li> <li><code>s</code> consists of only lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • firstUniqChar

      public int firstUniqChar(String s)