323. Keyboard Row
Easy
Membership Sets
Hashing
Problem
Given an array of English words, return the words that can be typed using letters from only one row of a standard American keyboard. Letter matching is case-insensitive. The result may be returned in any order.
Examples
Example 1
Input: ["Hello","Alaska","Dad","Peace"]
Output: ["Alaska","Dad"]
Example 2
Input: ["omk"]
Output: []
Example 3
Input: ["adsdf","sfd"]
Output: ["adsdf","sfd"]
Constraints
� 1 <= words.length <= 20
� 1 <= words[i].length <= 100
� words[i] consists of English letters.
Hints
?? Build a lookup from every letter to its keyboard row.
?? Every character in a valid word must map to the same row as its first character.
Expected Complexity
Time: O(total characters)
Space: O(1)
Follow-up
Can you represent the keyboard rows using sets or compact integer row identifiers?
Practice Notes
Attempts: 0
Time spent: 0min
Hints used: 0
JavaScript
00:00
Loading...
Case 1
Case 2
Case 3
Input
["Hello","Alaska","Dad","Peace"]Expected
["Alaska","Dad"]