Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- vector<string> findWords(vector<string>& words) {
- vector<string> result;
- for(auto&& w:words){
- if(isFine(w))
- result.push_back(w);
- }
- return result;
- }
- bool isFine(const string& s){
- auto line=m[s.front()];
- for(auto&& c:s){
- if(line!=m[c])
- return false;
- }
- return true;
- }
- Solution(){
- for(auto&& c:l1)
- m.insert({c,1});
- for(auto&& c:l2)
- m.insert({c,2});
- for(auto&& c:l3)
- m.insert({c,3});
- }
- string l1="qwertyuiopQWERTYUIOP";
- string l2="asdfghjklASDFGHJKL";
- string l3="zxcvbnmZXCVBNM";
- map<char,int> m;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement