给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。
/*** @param {string} s* @return {number}*/var firstUniqChar = function(s) {const map = {};for (let c of s) {if (map[c] === undefined) {map[c] = 1} else {map[c]++}}for (let i = 0; i < s.length; i++) {if (map[s[i]] === 1) {return i;}}return -1;};
