Description

Given an array of strings words, return the words that can be typed using letters of only one row of the American keyboard (qwertyuiop, asdfghjkl, zxcvbnm).

Examples

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

Alaska and Dad use one row.

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

The letters 'o', 'm', 'k' span multiple keyboard rows, so "omk" cannot be typed using a single row.

Input:words = ["typewriter","puppy","are","ZzZ"]
Output:["typewriter","puppy","are"]
Explanation:

typewriter uses only the top row (qwertyuiop), puppy uses only the middle row (asdfghjkl), and are uses only the middle row (asdfghjkl). ZzZ is excluded because it uses only the bottom row but demonstrates case insensitivity.

Constraints

  • 1 ≤ words.length ≤ 20

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!