17. Letter Combinations of a Phone Number

time :

space: O(n)

for example

new version

T: O(4^n*n), at most 4 digits, n is digits length, last *n => is String concat..

S: O(2*4 + n), dfs stack is n

better one I think

T: O(4^n*n), at last concat String with n times , n is digits length

S: O(n), recursion stack

Last updated

Was this helpful?