Skip to main content

Keyboard Row

EasyPremium

Given an array of strings words, return the words that can be typed using letters from only one row of a US keyboard. Keep them in their original order and capitalization.

The three letter rows are:

  • First row: qwertyuiop
  • Second row: asdfghjkl
  • Third row: zxcvbnm

Uppercase and lowercase letters count as the same key.

Example 1

Input: words = ["Hello", "Alaska", "Dad", "Peace"] Output: ["Alaska", "Dad"]

Every letter of Alaska and Dad is on the second row. Hello and Peace use more than one row.

Example 2

Input: words = ["omk"] Output: []

Constraints

  • 1 <= words.length <= 20
  • 1 <= words[i].length <= 100
  • words[i] contains only uppercase and lowercase English letters.