GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/387_First_Unique_Character_in_a_String.py at master · qiyuangong/leetcode Expand file tree/ Copy path387_First_Unique_Character_in_a_String.pyMore file actions 16 lines (15 loc) · 445 Bytes / Copy path387_First_Unique_Character_in_a_String.pyFile metadata and controls16 lines (15 loc) · 445 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class Solution(object): def firstUniqChar(self, s): """ :type s: str :rtype: int """ count_map = {} for c in s: count_map[c] = count_map.get(c, 0) + 1 for i, c in enumerate(s): if count_map[c] == 1: return i return -1 # def firstUniqChar(self, s): # min([s.find(c) for c in string.ascii_lowercase if s.count(c)==1] or [-1]) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |