20. First Non-Repeating Character
MediumStrings~12 min
Return the first character in a string that does not repeat anywhere else in the string.
If every character repeats, return an empty string.
Examples
Example 1
- Input:
- str = "leetcode"
- Output:
- "l"
Example 2
- Input:
- str = "aabb"
- Output:
- ""
- Why:
- Every character repeats.
Constraints
0 <= str.length <= 2000The string contains lowercase letters only.