dsa · easy

One-Row Words

A standard QWERTY keyboard has three letter rows:

Arguments

Given words, return every word that can be typed using letters from **only one** of those rows. Matching is case-insensitive (Dad uses the middle row). Keep the words in the same order they appear in words.

Example

words = ["Hello","Alaska","Dad","Peace"]

Hello mixes rows. Alaska and Dad stay on the middle row. Peace mixes rows. Result: ["Alaska","Dad"].

["omk"] uses more than one row → [].

Constraints

1 <= words.length <= 20 1 <= words[i].length <= 100 words[i] consists of English letters Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

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

Expected:
["Alaska","Dad"]

Example 2

Input:
["omk"]

Expected:
[]

Example 3

Input:
["adsdf","sfd"]

Expected:
["adsdf","sfd"]

Open in the Dojo editor