Open
Description
function FirstAppearingOnce() {
let minIndex = 256;
let strIndex = 0;
for (let i = 0; i < 256; i++) {
if (container[i] >= 0 && container[i] < minIndex) {
minIndex = container[i];
strIndex = i;
}
}
return minIndex === 256 ? '#' : String.fromCharCode(strIndex);
}
container[i] >= 0时,container[i]对应字符在字符串中的下标,所以实际使用时 minIndex = [传入的字符串长度或者无穷大]。
哈哈哈,当然这里不涉及具体问题,思路正确。
Metadata
Metadata
Assignees
Labels
No labels