zoukankan      html  css  js  c++  java
  • leetcode804

    int uniqueMorseRepresentations(vector<string>& words) {
        map<char, string> st;
        st.insert(make_pair('a', ".-"));
        st.insert(make_pair('b', "-..."));
        st.insert(make_pair('c', "-.-."));
        st.insert(make_pair('d', "-.."));
        st.insert(make_pair('e', "."));
        st.insert(make_pair('f', "..-."));
        st.insert(make_pair('g', "--."));
    
        st.insert(make_pair('h', "...."));
        st.insert(make_pair('i', ".."));
        st.insert(make_pair('j', ".---"));
        st.insert(make_pair('k', "-.-"));
        st.insert(make_pair('l', ".-.."));
        st.insert(make_pair('m', "--"));
        st.insert(make_pair('n', "-."));
    
        st.insert(make_pair('o', "---"));
        st.insert(make_pair('p', ".--."));
        st.insert(make_pair('q', "--.-"));
        st.insert(make_pair('r', ".-."));
        st.insert(make_pair('s', "..."));
        st.insert(make_pair('t', "-"));
    
        st.insert(make_pair('u', "..-"));
        st.insert(make_pair('v', "...-"));
        st.insert(make_pair('w', ".--"));
        st.insert(make_pair('x', "-..-"));
        st.insert(make_pair('y', "-.--"));
        st.insert(make_pair('z', "--.."));
    
        map<string, int> stt;
        int count = 0;
        for (auto s : words)
        {
            string str = "";
            for (auto c : s)
            {
                str += st[c];
            }
            cout << str << endl;
            if (stt.find(str) != stt.end())//存在
            {
                
            }
            else
            {
                stt.insert(make_pair(str, 1));
                count++;
            }
        }
        return count;
    }
  • 相关阅读:
    linux常见的编码转换
    linux sort的用法
    转--11个失败之后
    shell入门
    迟到
    必须要回答的问题
    【转载】个人开发者要掌握的时间规划建议
    Unity 碰撞检测 OnTriggerEnter 入门
    浅谈BUFF设计
    随机掉宝,对玩家来讲真的随机吗?
  • 原文地址:https://www.cnblogs.com/asenyang/p/9712512.html
Copyright © 2011-2022 走看看