剑指 Offer 50. 第一个只出现一次的字符
第一个只出现一次的字符
http://www.nowcoder.com/questionTerminal/1c82e8cf713b4bbeb2a5b31cf5b0417c
- 巧解
for(let s of str){ if(str.indexOf(s) === str.lastIndexOf(s)){ return str.indexOf(s); } } return -1;
- 使用哈希表
https://leetcode-cn.com/problems/di-yi-ge-zhi-chu-xian-yi-ci-de-zi-fu-lcof/solution/di-yi-ge-zhi-chu-xian-yi-ci-de-zi-fu-by-3zqv5/