剑指Offer --> Questions 35
来源:互联网 发布:熊猫手机直播软件下载 编辑:程序博客网 时间:2024/05/22 17:03
<span style="font-family:Courier New;font-size:12px;">#include <iostream>#include <string>#include <iterator>using namespace std;const int CHARNUM = 256;unsigned char firstNotRepeatingChar(const string &s);int main(){string s;cin >> s;cout << firstNotRepeatingChar(s) << endl;}unsigned char firstNotRepeatingChar(const string &s){if (s.size() == 0){cout << "invalid input.";return '\0';}unsigned charCountInString[CHARNUM];for (auto &count : charCountInString){count = 0;}string temp = s;auto bIter = temp.begin();auto eIter = temp.end();while (bIter != eIter){charCountInString[static_cast<unsigned>(*bIter)]++;bIter++;}bIter = temp.begin();while (bIter != eIter && charCountInString[*bIter] != 1){bIter++;}if (bIter == eIter){cout << "Don't have a character appear only one.";return '\0';}else{return *bIter;}}</span>
0 0
- 剑指Offer --> Questions 35
- Questions
- Questions
- questions
- Questions
- Questions
- questions
- Questions
- questions
- questions
- questions
- questions
- questions
- questions
- QUESTIONS
- 【31-35】剑指offer
- 剑指Offer-35
- 剑指offer面试题35
- GHOST使用教程
- ubuntu编译环境搭建需要的内容
- 《我的互联网方法论》 周鸿祎 --- 用户至上, 体验为王, 免费模式, 颠覆创新
- 爱情发生器:36个问题+4分钟对视=告别单身
- git log命令
- 剑指Offer --> Questions 35
- Problem H 一道水题
- Android入门--ListView使用总结
- android Jobscheduler的用法
- (2.2.1)设计模式一览
- 信号量-内核信号量、POSIX信号量、system V信号量
- Linxu内核中断
- 二级 长度为7的字符串除首位外其余五个字符按ascii码进行排序
- Leetcode: Fraction to Recurring Decimal