/**
* @param {string[]} words
* @return {string[]}
*/
var findWords = function (words) {
const firstRow = 'qwertyuiop';
const secondRow = 'asdfghjkl';
const thirdRow = 'zxcvbnm';
const result = [];
for (const word of words) {
const lowerCaseWord = word.toLocaleLowerCase();
const a = lowerCaseWord.split('').every((word) => firstRow.includes(word));
const b = lowerCaseWord.split('').every((word) => secondRow.includes(word));
const c = lowerCaseWord.split('').every((word) => thirdRow.includes(word));
if (a || b || c) {
result.push(word);
}
}
return result;
};
Runtime: 58 ms, faster than 98.18% of JavaScript online submissions for Keyboard Row.
Memory Usage: 42.1 MB, less than 29.55% of JavaScript online submissions for Keyboard Row.