Same Keyboard Row

On a QWERTY keyboard, letters are arranged in three rows, and some words can be typed without moving to another row. Given a list words, return only the words whose letters all belong to one row: qwertyuiop, asdfghjkl, or zxcvbnm. Letter case does not matter, but return the words in their original spelling.

Примеры

Ввод
["Hello", "Alaska", "Dad", "Peace"]
Вывод
["Alaska", "Dad"]
Ввод
["qwerty"]
Вывод
["qwerty"]
Ввод
["abc"]
Вывод
[]

Нужно реализовать

def find_keyboard_row(words: list[str]) -> list[str]:

Теги

setstringshashmap
PostgreSQLv16

Tady se objeví výsledek běhu kódu

Visible tests
1
Input
["Hello","Alaska","Dad","Peace"]
Expected["Alaska","Dad"]
2
Input
["qwerty"]
Expected["qwerty"]
3
Input
["abc"]
Expected[]
4
Input
["asdf","zxcv"]
Expected["asdf","zxcv"]
5
Input
["Hello","Alaska","Dad","Peace","Hello","Alaska"]
Expected["Alaska","Dad","Alaska"]
6
Input
["asdf"]
Expected["asdf"]
Focus radio
Paused · SomaFM · Fluid