-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyBoardsRow.cpp
More file actions
31 lines (27 loc) · 871 Bytes
/
KeyBoardsRow.cpp
File metadata and controls
31 lines (27 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class Solution {
public:
vector<string> findWords(vector<string>& words) {
string Row1 = "qwertyuiopQWERTYUIOP";
string Row2 = "asdfghjklASDFGHJKL";
string Row3 = "zxcvbnmZXCVBNM";
vector<string> Sol;
for(int i=0; i<words.size(); i++){
map<int, int> Map;
for(int j=0; j<words[i].length(); j++){
if(Row1.find(words[i][j]) != string::npos){
Map[1]++;
}
if(Row2.find(words[i][j]) != string::npos){
Map[2]++;
}
if(Row3.find(words[i][j]) != string::npos){
Map[3]++;
}
}
if(Map.size() == 1){
Sol.push_back(words[i]);
}
}
return Sol;
}
};