1 题目描述

  请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时,第一个只出现一次的字符是"l"。

输出描述:

  如果当前字符流没有存在出现一次的字符,返回#字符。

2 思路和方法, C++核心代码

 class Solution
{
public:
//Insert one char from stringstream
void Insert(char ch)
{
s = s + ch;
if(cha[ch])
cha[ch]++;
else
cha[ch] = ;
}
//return the first appearence once char in current stringstream
char FirstAppearingOnce()
{
int length = s.size();
for(int i=; i<length; i++){
if(cha[s[i]] == )
return s[i];
}
return '#';
}
private:
char cha[]={};
string s;
};

参考资料

https://blog.csdn.net/u012477435/article/details/83351659#_1529

最新文章

  1. 如何在ASP.NET MVC和EF中使用AngularJS
  2. [C++] Running time and Integer to String
  3. Windows下Nginx的启动、停止等命令
  4. Android开发之 adb 启动问题或是部署应用不成功,出现“The connection to adb is down, and a severe error has occured.”错误
  5. C++的异常处理
  6. 分享一个安卓中异步获取网络图片并自适应大小的第三方程序(来自github)
  7. Cloud Test 单页面即时监测功能上线!
  8. CSS伪类对象before和after的用法
  9. AngularJS自定义表单控件
  10. NVIDIA+关联2015写学校招收评论(嵌入式方向,上海)
  11. c# 实时监控数据库 SqlDependency
  12. Java Spring 在线程中或其他位置获取 ApplicationContext 或 ServiceBean
  13. JavaScript基础函数---李老师的
  14. Java_去除字符串空格
  15. Elasticsearch学习笔记(二)Search API 与 Query DSL
  16. Sequential Minimal Optimization (SMO) 算法
  17. set_magic_quotes_runtime set_magic_quotes_gpc
  18. springmvc返回json数据的工具类
  19. C语言条件编译
  20. 在Ubuntu下设置默认编辑器

热门文章

  1. docker容器连接
  2. 2018-2019 20165226 Exp 8 Web基础
  3. linux 9.故障修复和网络配置
  4. curl获得cookie数据&lt;转&gt;
  5. 004 API约定
  6. js监听浏览器剪贴板
  7. hppts的理解
  8. docker build doris-0.11.20-release source code
  9. (二十三)IDEA 构建一个springboot工程,以及可能遇到的问题
  10. [ kvm ] 学习笔记 8:Ovirt 基础及使用