We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 19fc86d commit a9ed72dCopy full SHA for a9ed72d
Algorithms/Keyboard Row/keyboard-row.js
@@ -0,0 +1,35 @@
1
+// Source : https://leetcode.com/problems/keyboard-row/
2
+// Author : Han Zichi
3
+// Date : 2017-02-07
4
+
5
+/**
6
+ * @param {string[]} words
7
+ * @return {string[]}
8
+ */
9
+var findWords = function(words) {
10
+ let keys = [
11
+ 'qwertyuiop',
12
+ 'asdfghjkl',
13
+ 'zxcvbnm'
14
+ ];
15
16
+ let ans = [];
17
18
+ words.forEach(function(item) {
19
+ let s = new Set();
20
+ let word = item.toLowerCase();
21
22
+ for (let letter of word) {
23
+ for (let i = 0; i < 3; i++)
24
+ if (keys[i].indexOf(letter) !== -1) {
25
+ s.add(i);
26
+ break;
27
+ }
28
29
30
+ if (s.size === 1)
31
+ ans.push(item);
32
+ });
33
34
+ return ans;
35
+};
0 commit comments