Re: [闲聊] 每日LeetCode

楼主: wu10200512 (廷廷)   2024-02-05 09:15:27
※ 引述 《JerryChungYC (JerryChung)》 之铭言:
:  
: https://leetcode.com/problems/first-unique-character-in-a-string
:  
: 387. First Unique Character in a String
:  
: 给一个字串s,找到第一个不重复的字符回传其索引,不存在则回传-1
:  
: Example 1:
: Input: s = "leetcode"
: Output: 0
:  
: Example 2:
: Input: s = "loveleetcode"
: Outpue: 2
:  
: Example 3:
: Input: s = "aabb"
: Output: -1
:  


这题我只想到
第一个for循环建unordered_map
第二个for循环找第一个key的value为1的
还有别的解法吗

Links booklink

Contact Us: admin [ a t ] ucptt.com