LeetCode500. Keyboard Row我的C++解法
来源:互联网 发布:加工中心倒角c怎么编程 编辑:程序博客网 时间:2024/05/22 03:53
Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.
Example 1:
Input: ["Hello", "Alaska", "Dad", "Peace"]Output: ["Alaska", "Dad"]
Note:
- You may use one character in the keyboard more than once.
- You may assume the input string will only contain letters of alphabet.
class Solution {public: vector<string> findWords(vector<string>& words) { string rows[] = {"qwertyuiop", "asdfghjkl", "zxcvbnm"}; vector<string> vs; for (int i = 0; i < words.size(); i++) { string s = words[i]; int r = -1; int j = 0; for (j = 0; j < s.size(); j++) { if (r == -1) { while (r < 2) { r++; if (string::npos != rows[r].find(tolower(s[j]))) { break; } } } else { if (string::npos == rows[r].find(tolower(s[j]))) { break; } } } if (j == s.size()) { vs.push_back(s); } } return vs; }};
0 0
- LeetCode500. Keyboard Row我的C++解法
- leetcode500: Keyboard Row
- leetcode500 Keyboard Row Java
- Leetcode500. Keyboard Row
- leetcode500. Keyboard Row
- LeetCode500. Keyboard Row
- Leetcode500. Keyboard Row
- python--leetcode500. Keyboard Row
- 14.leetCode500:keyboard row
- 500. Keyboard Row的C++解法
- 【leetcode】Keyboard Row题目的C++解法
- Keyboard Row问题及解法
- leetcode[Keyboard Row]//待整理多种解法
- 我的学习之旅 keyboard.h和keyboard.c
- 我的学习之旅keyboard.h和keyboard.c
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Qt之QThread用法
- 51NOD 1109 01组成的N的倍数
- Android FrameWork源码浅析之(二)--转发一篇文章讲binder
- 欢迎使用CSDN-markdown编辑器
- (android)内容提供者contentprovider(-)
- LeetCode500. Keyboard Row我的C++解法
- 面试题-华为-进制转换-3
- poj 2777,hdu 5023 线段树区间染色+lazy+位运算
- 关于GIMP油漆桶工具使用出错的问题
- scrum理解
- 1027. Colors in Mars 解析
- C++的一些知识以及和C语言的不同
- ZCMU-1416-Find the Lost Sock
- java服务器代理线程