문제 링크[새 창]

 

class Solution:
    def firstUniqChar(self, s: str) -> int:
        """
        :type s: str
        :rtype: int
        """
        # build hash map : character and how often it appears
        count = collections.Counter(s)
        
        # find the index
        for idx, v in enumerate(s):  # 인덱스, 값 동시 접근하기 
            if count[v] == 1:
                return idx     
        return -1
 

'Python 문제풀이 > LeetCode' 카테고리의 다른 글

Valid Anagram  (0) 2021.09.03
Reverse Integer  (0) 2021.09.01
Reverse String  (0) 2021.08.26
Rotate Image **  (0) 2021.08.18
Valid Sudoku **  (0) 2021.08.11
블로그 이미지

hjc_

୧( “̮ )୨

,