X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Convert a sentence into its equivalent mobile numeric keypad sequence
Easy Accuracy: 68.08% Submissions: 6419 Points: 2

Given a sentence in the form of a string in uppercase, convert it into its equivalent mobile numeric keypad sequence.

 

Example 1:

Input:
S = "GFG"
Output: 43334
Explanation: For 'G' press '4' one time.
For 'F' press '3' three times.

Example 2:

Input:
S = "HEY U"
Output: 4433999088
Explanation: For 'H' press '4' two times.
​For 'E' press '3' two times. For 'Y' press '9' 
three times. For white space press '0' one time.
For 'U' press '8' two times.

 

Your Task:  
You dont need to read input or print anything. Complete the function printSequence() which takes a string as input parameter and returns
its equivalent mobile numeric keypad sequence as a string.
 

Expected Time Complexity: O(Length of String)
Expected Auxiliary Space: O(Length of String)

 

Constraints:

1 <= Length of String <= 105
Characters of string can be empty space or capital alphabets.

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Convert a sentence into its equivalent mobile numeric keypad sequence

Output Window