3-line C++ Regular Expression Solution


  • 0
    class Solution {
    public:
        vector<string> findWords(vector<string>& words) {
            vector<string> v;
            for(auto w:words) regex_match(w,regex("[QWERTYUIOPqwertyuiop]*|[ASDFGHJKLasdfghjkl]*|[ZXCVBNMzxcvbnm]*"))?v.push_back(w):(void)0;
            return v;
        }
    };
    

Log in to reply
 

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