500 Keyboard Row

Given a List of words, return the words that can be typed using letters ofalphabeton only one row's of American keyboard like the image below.

American keyboard

Example 1:

Input:
 ["Hello", "Alaska", "Dad", "Peace"]

Output:
 ["Alaska", "Dad"]

Note:

  1. You may use one character in the keyboard more than once.

  2. You may assume the input string will only contain letters of alphabet.

The Idea:

  1. Check the row it belongs in.

  2. Confirm that all characters exist in that row.

Last updated

Was this helpful?