Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class Solution {
  2. public:
  3. vector<string> findWords(vector<string>& words) {
  4. vector<string> result;
  5.  
  6. for(auto&& w:words){
  7. if(isFine(w))
  8. result.push_back(w);
  9. }
  10. return result;
  11. }
  12.  
  13. bool isFine(const string& s){
  14. auto line=m[s.front()];
  15. for(auto&& c:s){
  16. if(line!=m[c])
  17. return false;
  18. }
  19.  
  20. return true;
  21. }
  22.  
  23. Solution(){
  24. for(auto&& c:l1)
  25. m.insert({c,1});
  26. for(auto&& c:l2)
  27. m.insert({c,2});
  28. for(auto&& c:l3)
  29. m.insert({c,3});
  30. }
  31.  
  32. string l1="qwertyuiopQWERTYUIOP";
  33. string l2="asdfghjklASDFGHJKL";
  34. string l3="zxcvbnmZXCVBNM";
  35. map<char,int> m;
  36. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement