2025-01-09 20:29:41 +08:00
< p > Given a string < code > s< / code > , find the < strong > first< / strong > non-repeating character in it and return its index. If it < strong > does not< / strong > exist, return < code > -1< / code > .< / p >
2022-03-27 20:56:26 +08:00
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2025-01-09 20:29:41 +08:00
< div class = "example-block" >
< p > < strong > Input:< / strong > < span class = "example-io" > s = " leetcode" < / span > < / p >
< p > < strong > Output:< / strong > < span class = "example-io" > 0< / span > < / p >
< p > < strong > Explanation:< / strong > < / p >
< p > The character < code > ' l' < / code > at index 0 is the first character that does not occur at any other index.< / p >
< / div >
< p > < strong class = "example" > Example 2:< / strong > < / p >
< div class = "example-block" >
< p > < strong > Input:< / strong > < span class = "example-io" > s = " loveleetcode" < / span > < / p >
< p > < strong > Output:< / strong > < span class = "example-io" > 2< / span > < / p >
< / div >
< p > < strong class = "example" > Example 3:< / strong > < / p >
< div class = "example-block" >
< p > < strong > Input:< / strong > < span class = "example-io" > s = " aabb" < / span > < / p >
< p > < strong > Output:< / strong > < span class = "example-io" > -1< / span > < / p >
< / div >
2022-03-27 20:56:26 +08:00
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = s.length < = 10< sup > 5< / sup > < / code > < / li >
< li > < code > s< / code > consists of only lowercase English letters.< / li >
< / ul >