"""
387
first unique character in a string
easy

Given a string s, return the first non-repeating character in it and
return its index. If it does not exist, return -1.
"""


class Solution:
    def firstUniqChar(self, s: str) -> int:

        hash = {}
        for c in s:
            if c in hash:
                hash[c] += 1
            else:
                hash[c] = 1

        for i in range(len(s)):
            if hash[s[i]] == 1:
                return i

        return -1



