剑指offer: 字符流中第一个不重复的字符

class Solution
{
public:
  //Insert one char from stringstream
    void Insert(char ch)
    {
          vec.push_back(ch);
          mapdata[ch]++;
    }
  //return the first appearence once char in current stringstream
    char FirstAppearingOnce()
    {
          vector<int>::iterator it;
          for(it=vec.begin();it!=vec.end();it++)
          {
               if(mapdata[*it]==1)
                    return *it;
          }
      return #;
    }
         map<char,int> mapdata;
         vector<int> vec;
};
2020-05-01
在牛客打卡22天,今天学习:刷题 1 道/代码提交 1 次
全部评论

相关推荐

04-28 11:34
西北大学 运营
牛客4396号:不好意思,这个照片猛一看像丁真
点赞 评论 收藏
分享
吴offer选手:我卡在笔试才是最好笑的,甚至没给我发过笔试链接
投递哔哩哔哩等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务