首页 > 其他 > 详细

字符流中第一个不重复的字符

时间:2019-07-24 18:01:48      阅读:117      评论:0      收藏:0      [点我收藏+]

技术分享图片

 1 class Solution
 2 {
 3 public:
 4   //Insert one char from stringstream
 5     void Insert(char ch)
 6     {
 7         s+=ch;
 8         m[ch]++;
 9     }
10   //return the first appearence once char in current stringstream
11     char FirstAppearingOnce()
12     {
13         for(int i=0;i<s.size();i++){
14             if(m[s[i]]==1) return s[i];
15         }
16         return #;
17     }
18 private:
19     string s;
20     unordered_map<char,int> m;
21 };

 

字符流中第一个不重复的字符

原文:https://www.cnblogs.com/pacino12134/p/11239399.html

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