Javascript Solution


  • 0
    H
    /**
     * @param {string} s
     * @return {number}
     */
    var firstUniqChar = function(s) {
        s = s.split('');
        for(let i=0; i<s.length;i++){
            if (s.lastIndexOf(s[i]) == i && s.indexOf(s[i]) == i){
                return i;
            }
        }
        return -1;
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.