#=================================== # Tanzila Islam # Email: tanzilamohita@gmail.com # Language: Python 3 #=================================== class Solution: def firstUniqChar(self, s: str) -> int: save_idx = {} for val in s: if val in save_idx: save_idx[val] += 1 else: save_idx[val] = 1 for idx, val in enumerate(s): if save_idx[val] == 1: return idx return -1
No comments:
Post a Comment