Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 443 Bytes

剑指 Offer 50. 第一个只出现一次的字符.md

File metadata and controls

17 lines (15 loc) · 443 Bytes
function firstUniqChar(s: string): string {
    const map: { [key: string]: number } = Object.create(null);
    for (const key of s) {
        map[key] = (map[key] || 0) + 1;
    }
    for (const key in map) {
        if (map[key] === 1) {
            return key;
        }
    }
    return ' ';
};