This is insane, i wasnt able to understand the neetcode solution, but i am able to understand this! Thanks
@thisissheraf26332 ай бұрын
NeetCode is also good, however, this is a simplified version with a dp array, and coming up with this solution in an unseen problem is very difficult. Please develop the understanding with recursion + memoization as explained by neetcode, it will be very helpful long term.
@LinhHoang-ml1qo2 ай бұрын
@@thisissheraf2633 Agree!
@gamasterprochannel8563 ай бұрын
This man is genius
@chandan07talreja8 ай бұрын
Thanks for detailed explanation Nikhil. Really appreciate it.
@Md_sadiq_Md8 ай бұрын
Pushing the algorithm
@yomamasofat4133 ай бұрын
bro who would be able to come up with this solution if he has never seen it before in an interview? Crazy man
@nivedhitha7042 ай бұрын
very very perfect solution....i love this explanation...u made it very easy to understand for beginners...thank you so much sir
@floatingfortress7215 ай бұрын
Thank you very much! You were able to simplify the problem for me and now I actually understand it
@rudreshcm41728 ай бұрын
Hey nikhil, first of all thanks for your top notch leetcode video solutions. Can you please make one video that should provide roadmap specific to your uploaded playlists/videos. This really make difference and increase watch count.
@nikoo287 ай бұрын
I have created some playlists, but yes...can define a better roadmap too. Will work on it. Thanks. :)
@Satya-g5tАй бұрын
always good explanation, consistent and patient with no hurry, cool. 😃
@banadipmudi3186Ай бұрын
Thanks brother, amazing explanation
@KoundinyaKoorapati-o8vАй бұрын
Nikhil you make things so simple. I really wish you conducted some course in DSA. Thank You.
@satyadharkumarchintagunta379329 күн бұрын
Thanks bro! Neat and clear explanation.
@sanjith30752 ай бұрын
this video cleared my doubts , tqsm
@shubhamsharma88203 ай бұрын
very well explained
@akshitjain29065 ай бұрын
legend
@prashanthshetty83377 ай бұрын
Thank you very much for the detailed explanation. instead of dp[], we could use 2 place holders to keep track of previous sum right? all we care is i-1 and i-2 can be tracked as prev1 and prev2.
@nikoo287 ай бұрын
That's a great idea! Will save you space.
@Techgether4 ай бұрын
"dp[0] = 1 because there is 1 way to decode it, which is not doing anything"... this is not doing anything but still counted as 1 way????? kinda contradict when its only counted as 1 if there is something to decode, which is why when digit is 0, there is 0 way to decode.. but when digit is empty which is at 0 index, now its counted as 1.. this is hard to understand..
@benmyths2 ай бұрын
also in counting stair problem there was a base condition where when you are standing on 0th stairs, theres only 1 way to reach it that is by doing nothing. so dp[0] = 1 😂😂😂 man its so confusing
@tamils123456 ай бұрын
class Solution { public: int numDecodings(string s) { vector dp(s.length() + 1); dp[0] = 1; dp[1] = (s.at(0) == '0')?0:1; for(int i = 2; i= 1) { dp[i] += dp[i-1]; } if (double_digit >= 10 && double_digit
@jst89225 ай бұрын
The issue stems from how you're extracting single and double-digit numbers using stoi and substr. Here's a breakdown of the problem and the solution: Problem: Incorrect Substring Extraction: The substr(i-1, i) in stoi(s.substr(i-1, i)) doesn't extract a single digit. Instead, it extracts a substring from index i-1 up to (but not including) index i. This means you're always getting a two-character substring (except for the last iteration). Unnecessary stoi: You don't need stoi to check if a single digit is between 1 and 9. A simple character comparison is more efficient. tested & working on lc class Solution { public: int numDecodings(string s) { int n = s.length(); vector dp(n + 1); dp[0] = 1; // Empty substring has one way to decode dp[1] = (s[0] == '0') ? 0 : 1; // First digit can't be '0' for (int i = 2; i = 1 && single_digit = 10 && double_digit
@tamils123455 ай бұрын
@@jst8922 thanks man.
@imdarkseid23433 ай бұрын
@@tamils12345 Bro neenga final year ah bro
@tamils123453 ай бұрын
@@imdarkseid2343 no. Working
@GmHighlight126 ай бұрын
What if String length only 2 this code will failed to execute
@SevDeuceOff6 ай бұрын
I tested with string length as 2. It works. Can you share specific examples that failed for you ?
@GmHighlight126 ай бұрын
Try to run this code on leetcode all test cases won’t pass
@SevDeuceOff6 ай бұрын
@@GmHighlight12 It does pass all test cases. I tore the code to determine the breakage point. Looks like you may be hinting at the test case "10". Is that the one ?
@sriyanandakuchimanchi40425 ай бұрын
no it will work instead of writing dp[1] like that.,,add this check if(s.charAt(0)=='0'||s.length==0||s==null){ return 0; }