Unique Character
STRING

Problem

Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.

Examples

uniqChar("algorithm") // returns 0 // The character 'a' is the first non-repeating character uniqChar("javaj") // returns 2 // The character 'v' is the first non-repeating character uniqChar("abccba") // returns -1 // All characters are appearing more than once
Loading...