题解 | #找出字符串中第一个只出现一次的字符#
找出字符串中第一个只出现一次的字符
http://www.nowcoder.com/practice/e896d0f82f1246a3aa7b232ce38029d4
let arr=readline().split('')
let res = []
for (let i = 0; i < arr.length; i++) {
if (arr.indexOf(arr[i]) < i) {
let index = res.indexOf(arr[i])
res.splice(index, 1)
} else {
res.push(arr[i])
}
}
if (res.length) {
console.log(res[0])
} else {
console.log(-1)
}