Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6420
@blackshadows 6376
@mb1973 5604
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Complete Leaderboard
Convert a sentence into its equivalent mobile numeric keypad sequence
Easy Accuracy: 80.77% Submissions: 26 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