DEV Community

Discussion on: LeetCode WalkThru: 'First Unique Character in a String'

Collapse
 
shubhamb profile image
Shubham_Baghel

This is really nice post with great explanation,but code seems some issue here you can find updated working code of it

 for (i=0; i < s.length; i++) {
      if (s.indexOf(s[i]) == s.lastIndexOf(s[i])) {
        return i
      }
    }
   return -1
Enter fullscreen mode Exit fullscreen mode