As reported: ServiceNow Software Engineer (IC2) loop, round 2 (60-minute technical, Java backend + JavaScript frontend), Jun 2025: decode T9-style keypad input, where a letter that is the first letter of a key's group finishes the previous character.
On a phone keypad, letters are grouped on keys: abc, def, ghi, jkl, mno, pqrs, tuv, wxyz. To type a letter you press its key repeatedly; the screen shows the group's letters in order (p, then q, then r, …), and the last one shown is the letter typed.
You are given s, the sequence of letters that appeared on screen while a word was typed. A letter that is the first letter of a group (a d g j m p t w) always starts a new character, which finishes the character before it. Return the word that was typed.
Example
"ppqrammnod" -> "pramod" (p | pqr | a | m | mno | d)
"pp" -> "pp"
"abcat" -> "cat" (abc | a | t)
Constraints: 1 ≤ s.length ≤ 10^5; s is valid: it splits into runs, each run starting with a group's first letter and continuing with that group's next letters in order.
Code runner format: one line with s as a JSON string. Implement decodeT9(s); the harness prints the decoded word.