class Solution
{
public:
vector<string> findWords(vector<string>& words)
{
vector<string>ans;
string line1 = "qwertyuiop";
string line2 = "asdfghjkl";
string line3 = "zxcvbnm";
for (int i = 0; i < words.size(); i++)
{
int j = 0;
while (line1.find(tolower(words[i][j])) != string::npos)
{
j++;
if (j == words[i].length())
ans.push_back(words[i]);
}
j = 0;
while (line2.find(tolower(words[i][j])) != string::npos)
{
j++;
if (j == words[i].length())
ans.push_back(words[i]);
}
j = 0;
while (line3.find(tolower(words[i][j])) != string::npos)
{
j++;
if (j == words[i].length() )
ans.push_back(words[i]);
}
}
return ans;
}
};
500.键盘行
猜你喜欢
转载自blog.csdn.net/kongqingxin12/article/details/84309247
今日推荐
周排行