C++ Using STL


  • 0
    M
    class Solution {
    public:
        vector<string> findWords(vector<string>& words) {
            vector<string> result;
            copy_if(words.begin(), words.end(), back_inserter(result), [](string w){
                transform(w.begin(), w.end(), w.begin(), ::tolower);
                return (w.find_first_of("qwertyuiop") != -1) + (w.find_first_of("asdfghjkl") != -1) + (w.find_first_of("zxcvbnm") != -1) == 1;
            });
            return result;
        }
    };
    

Log in to reply
 

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