In this lesson, you’ll use what you learned in the previous sections to solve a medium real world interview question. Medium means something you might find in a technical phone screen or an onsite interview.
Here’s the question:
def keypad_string(keys):
'''
Given a string consisting of 0-9,
find the string that is created using
a standard phone keypad
| 1 | 2 (abc) | 3 (def) |
| 4 (ghi) | 5 (jkl) | 6 (mno) |
| 7 (pqrs) | 8 (tuv) | 9 (wxyz) |
| * | 0 ( ) | # |
You can ignore 1, and 0 corresponds to space
>>> keypad_string("12345")
'adgj'
>>> keypad_string("4433555555666")
'hello'
>>> keypad_string("2022")
'a b'
>>> keypad_string("")
''
>>> keypad_string("111")
''
'''
The entire solution will be available at the end of the course. Try the problem yourself and then watch the video for the solution.
You heard about Big O analysis, which is a way to analyze the speed and memory usage of a function or block of code. See Wikipedia Time complexity for more information.
Bartosz Zaczyński RP Team on Nov. 5, 2021
@douglast Whether you can use Google or not during a job interview depends on who will be interviewing you. I’ve been in both situations. At one time, a third-party recruiting company was handling the pre-screening through an online tool, which didn’t even allow me to use copy and paste for my coding challenge. The first time I tried that, it gave me a final warning and threatened to fail the test. However, in a different company, the interviewers were okay with searching for information online, so it really boils down to who you’ll be dealing with.