what would be time complexity in this case?
Phone Keypad problem using recursion
Time Complexity: O(4^n), where n is number of digits in input number.
Each digit of a number has 3 or 4 alphabets, so it can be said that each digit has 4 alphabets as options. If there are n digits then there are 4 options for first digit and for each alphabet of first digit there are 4 options in second digit, i.e for every recursion 4 more recursion is called (if it does not match the base case). So the time complexity is O(4^n).
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.