Keyboard Row

EasyStringshashing

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

On a standard American QWERTY keyboard the letters sit on three rows: - row 1: qwertyuiop - row 2: asdfghjkl - row 3: zxcvbnm Given an array of strings words, return the words that can be typed using letters from only one of these rows. Letter case does not matter ('A' is on the same row as 'a'). Return the qualifying words exactly as given, in the same order they appear in words.

Examples

Input: words = ["Hello","Alaska","Dad","Peace"]
Output: ["Alaska","Dad"]
"Alaska" and "Dad" use only row 2; the other words mix rows.
Input: words = ["omk"]
Output: []
`o` is on row 1 but `m` is on row 3.
Input: words = ["adsdf","sfd"]
Output: ["adsdf","sfd"]
Both words use only row 2.

Constraints

  • 1 <= words.length <= 20
  • 1 <= words[i].length <= 100
  • `words[i]` consists of lowercase and uppercase English letters

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More hashing problems