C++ solution


  • 0
    M

    '''
    class Solution {
    public:

    vector<string> keyBoard = 
    {
        {"qwertyuiop"}, {"asdfghjkl"}, {"zxcvbnm"}
    };
    
    vector<string> findWords(vector<string>& words) {
        vector<string> result;
        for(auto word: words)
        {
            int countEnter = 0;
            for(auto strSimbol: keyBoard)
            {
                for(auto charWord: word)
                {
                    for(auto charStrSimbol: strSimbol)
                    {
                        if(charWord == charStrSimbol || toupper(charWord) == toupper(charStrSimbol))
                        {
                            countEnter++;
                            break;
                        }
                    }
                }
                if(countEnter != word.size() && countEnter != 0)
                    break;
                else if(countEnter == word.size())
                {
                    result.push_back(word);
                    break;
                }    
            }
        }
        return result;
    }
    

    };
    ''''


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.