Total Ways To Decode A String - Recursive Dynamic Programming Approach ('Decode Ways' on LeetCode)

preview_player
Показать описание
📹 Intuitive Video Explanations
🏃 Run Code As You Learn
💾 Save Progress
❓New Unseen Questions
🔎 Get All Solutions

Question: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - 1 'B' - 2 ... 'Z' - 26. Given a non-empty string containing only digits, determine the total number of ways to decode it.

Examples:

1
Input: "12"
Output: 2
Explanation: It could be decoded as "AB" (1 2) or "L" (12).

2
Input: "226"
Output: 3
Explanation: It could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6).

Complexities:

n is the total digits in the input string

Time: O( n )
Memoization prunes our recursion tree and we will do a linear amount of work to solve the problem.

Space: O( n )
We will need to store the answer to up to n subproblems that we will need to calculate

++++++++++++++++++++++++++++++++++++++++++++++++++

Рекомендации по теме
Комментарии
Автор

Table of Contents:

Messing Around 0:00 - 1:16
The Problem Introduction 1:16 - 2:54
Recursion Tree Walkthrough 2:54 - 8:06
Pruning The Recursion (With Memoization) 8:06 - 10:26
Time Complexity 10:26 - 10:40
Space Complexity 10:40 - 11:22
Yeah 11:22 - 11:38

The solution for this problem as described in the video is in the description.

BackToBackSWE
Автор

The recursion code is not in the description. :(
Please provide the link.
Thanks

rahul-patil
Автор

Hey man, I just really love how you teach the concepts and not the coding. We can find the code in whatever language on LC but this is actually really helping me understand how to get to the answer - keep up the great work! :)

cemtorun
Автор

I had a facebook phone interview last week. It's exactly this But I couldn't solve it at that time. I felt really depressed. Thanks for this video! I become more clear about DFS.

frankchen
Автор

Your way of explaining first the problem with the O(2n) approach then going to the optimised one really helps a lot. Thanks for your rich videos. :)

meghamalviya
Автор

when you just dropped the time complexity from exponential to linear by pruning the tree .. BRAINS OUT !!
Amazing, really helpful!

acousticIndie
Автор

I like how you explain the problem/solution without using code in the video. It lets me understand what needs to be done without giving me a bias on how to code a solution when I re-attempt the problem.

TheKarateKidd
Автор

this is my first video on your channel, i dont know dp, currently i am learning recursion only, man your explanation is outstanding! I love it, , thank you

awalktoinfinity
Автор

This explanation is one of the most intuitive explanations i have found on the internet...KUDOS!!!

password
Автор

Well i must say that you explained the concept of dynamic programming deeply in this video and actually made me realize that how to think from the basic . Thanks !

meghnaverma
Автор

The way u explain the logic using recursion tree is superb.... Thank you

aj
Автор

You have a great knack for explaining these problems. Fantastic Work!

jeffmathew
Автор

Really Really good man. Understood the solution in depth. The Recursion tree helped a lot. Keep up the good work.

RahulVerma-fzjf
Автор

I've seen a few videos until now, and I can say your explanations are always better than others😊Thank you always. And I also love your clear voices!

jinny
Автор

I am just wondering there code is ? I didn't find anything in the description

xiaofalin
Автор

Hey! Great explanation but where's the code for this question??? I can't find it in the description.

pranavpallavalli
Автор

Exactly what I was looking for ... a recursive solution. Thanks man.

spk
Автор

The best explanation I have heard ...thank you 😊

ashmitaroy
Автор

Thanks to show me the recursion approach of this problem. If I had skipped to DP solution, I would never understand the reason behind this problem. Recursion, then memoization and then DP (Bottom UP approach) is the best sequence. DP is hard and your videos is really making me understand DP. I know that I need practice, practice and practice.

gustavoy
Автор

Dude your intros are the best lol. Thanks a lot for your videos!

axchetype