🟢 剑指 Offer 50. 第一个只出现一次的字符
LeetCode 提示
题目难度 简单
原题链接 🔗 leetcode
#
题解 1.pyclass Solution: def firstUniqChar(self, s: str) -> str: d = {} for idx, ch in enumerate(list(s)): if ch in d: d[ch] = -1 else: d[ch] = idx minChar = ' ' minIdx = len(s) for k, val in d.items(): if val >= 0 and val < minIdx: minIdx = val minChar = k return minChar