#K5526. Letter Combinations of a Phone Number

    ID: 29936 Type: Default 1000ms 256MiB

Letter Combinations of a Phone Number

Letter Combinations of a Phone Number

Given a string containing digits from 2 to 9, return all possible letter combinations that the number could represent, according to the traditional telephone keypad mapping. For instance, the digit 2 corresponds to the letters abc, the digit 3 to def, and so on. In mathematical terms, the mapping can be represented as $$ d \to mapping[d] $$ where, for example, $$ mapping[2]=\text{'abc'} $$. The resulting combinations must be listed in lexicographical order.

inputFormat

A single line containing a non-empty string of digits (from 2 to 9).

outputFormat

Print each possible letter combination on a new line in lexicographical order. If there are no combinations, output nothing.## sample

23
ad

ae af bd be bf cd ce cf

</p>