First unique character
MediumHash maps · JavaScript
The task
Write firstUniqueChar(s) that returns the index of the first character in s that appears exactly once.
If there is none, return -1.
Examples
- firstUniqueChar("leetcode") returns 0
- firstUniqueChar("aabb") returns -1
Your code runs in your browser, in a separate worker, and is never sent to us. Edit the function, then press Run tests. Your work is saved here as you type.
JavaScriptCtrl or Cmd + Enter to run