#C12390. Keyboard Row Words

    ID: 41812 Type: Default 1000ms 256MiB

Keyboard Row Words

Keyboard Row Words

You are given a JSON array which may contain words (strings) and other non-string elements. Your task is to filter out and output only those words that can be typed using letters of a single row on a standard QWERTY keyboard.

The QWERTY keyboard rows are defined as follows:

  • Row 1: \(qwertyuiop\)
  • Row 2: \(asdfghjkl\)
  • Row 3: \(zxcvbnm\)

The filtering must be case insensitive and non-string elements should be ignored.

Examples:

  • Input: ["Hello", "Alaska", "Dad", "Peace"] → Output: ["Alaska", "Dad"]
  • Input: ["HeLLo", "ALAska", "dAD", "pEACe"] → Output: ["ALAska", "dAD"]

inputFormat

The input is given via standard input as a single line containing a JSON array. Each element in the array may be a string or another type (number, null, boolean, etc.). Only the string elements should be considered. For example:

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

outputFormat

Output a JSON array (printed on a single line) containing the words that can be typed using letters from only one row on a QWERTY keyboard. For example:

["Alaska","Dad"]
## sample
["Hello", "Alaska", "Dad", "Peace"]
["Alaska","Dad"]