首页 > 其他 > 详细

剑指OFFER----面试题50. 第一个只出现一次的字符

时间:2020-03-08 11:08:12      阅读:39      评论:0      收藏:0      [点我收藏+]

链接:https://leetcode-cn.com/problems/di-yi-ge-zhi-chu-xian-yi-ci-de-zi-fu-lcof/

代码

class Solution {
public:
    char firstUniqChar(string s) {
        unordered_map<char, int> count;
        for (auto c: s) {
            count[c]++;
        }
        for (auto c: s) {
            if (count[c] == 1) {
                return c;
            }
        }
        return ' ';
    }
};

剑指OFFER----面试题50. 第一个只出现一次的字符

原文:https://www.cnblogs.com/clown9804/p/12441364.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!