中国制造网网站特色,网站建设企业 熊账号,全国门户网站有哪些,网站建设与开发开题报告在一个字符串(0字符串长度10000#xff0c;全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1#xff08;需要区分大小写#xff09;. 解法#xff1a;
class Solution {
public:int FirstNotRepeatingChar(string str) {unordered… 在一个字符串(0字符串长度10000全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1需要区分大小写. 解法
class Solution {
public:int FirstNotRepeatingChar(string str) {unordered_mapchar, int mp;for(auto c : str) mp[c];for(int i 0; i str.size(); i){if(mp[str[i]] 1)return i;}return -1;}
};