zoukankan      html  css  js  c++  java
  • 查找第一个只出现一次的字符

    #include "stdafx.h"
    #include <string>
    using namespace std;
    #include <vector>
    #include <map>

    class Solution
    {
    public:
        int  find_right_char(string str)
        {
            int strLen = str.size();
            if (strLen ==0)
            {
                return -1;
            }
            map<char,int> item;
            for (size_t i = 0; i < strLen; i++)
            {
                item[str[i]] = item[str[i]] + 1;
            }

            for (size_t i = 0; i < strLen; i++)
            {
                if (item[str[i]] ==1)
                {
                    return str[i];
                }
            }
            return -1;
        }
    };



    int main()
    {
        Solution aa;
        string str = "12312";
        aa.find_right_char(str);
        return 1;
    }

    天天向上
  • 相关阅读:
    调试
    自定义缓冲函数
    缓冲
    如何控制动画
    开发中遇到过的坑
    动画控制属性
    自定义动画
    CATransition(过渡)
    动画基础(显式动画)
    呈现图层
  • 原文地址:https://www.cnblogs.com/hg07/p/12702052.html
Copyright © 2011-2022 走看看