Problem : https://leetcode.com/problems/first-unique-character-in-a-string/
class Solution:
def firstUniqChar(self, s: str) -> int:
counter = Counter(s)
for i, n in enumerate(s):
if counter[n] == 1: return i
return -1
No comments:
Post a Comment