Excellent explanation I honestly was dreading to do this for the past few days. As soon as I watched your video I got it. Wish I had watched it sooner.
Huh! I was almost lost while reading the leetcode solution, but I know you can give me hope. Would love to see solutions for more top-ranked questions from you. Thank you.
can you explain more about why we still need to pop when cur_char is a letter? is it due to a greedy way of thinking that even if the letter pops, if the res is valid (with/without letter) the max length should always include the letter?
Its because curr_res is pointing to a reference instead of a new array. So we always need to pop() in order to leave the array at its before state for the next recursive call. We can remove the need for pop by inputting a new array into every function call but this take more space since we will have multiple copies of the array for each call stack.
Thanks for posting the leetcode solutions. I really enjoy your channel. I have a meta interview coming up for a DE position, is python technical coding interview for DE easier than that for SWE? I find python medium in leetcode still pretty hard unless I have solved the exact question before.
Awesome explanation :) it doesnt seem to be hard after all! Can you do the most asked meta question 2060 Check if an Original String Exists Given Two Encoded Strings
Yea it really isn’t. But I guess you need to see the solution once and then it’s easy. I’ve had a lot of people request 2060… it’s quite difficult and I’m not quite sure how to solve it. Need to research it more but I wouldn’t worry because Meta doesn’t ask these sorts of really hard questions normally
:) its similar to Subset problem which is also a backtracking. Just including and excluding the current digit to form a subset. Hence said it wasn’t hard after all
You need to do backtracking to understand that. Notice we only pop when we added to cur_res? Thats what backtracking does. When we go back up the tree we need to pop what we had added.
consider "(a)". you start by including and not including the first "(" . 1. Let's say you start with including it - so you string becomes "(" now. 2. in the next step you include "a" , which makes it "(a". Now, here if you don't pop "a", when you go back to step1 and execute pop (hoping for "(" to pop), you are actually popping "a" instead.
when you encounter the ) in ()()')'( for the first time... you dont take ) because left_count == right_count, (In order to consider ) the left_count < right_count. The result for that will be ()()
Thank you for the great explanation. Have you ever solved question 65 using Deterministic Finite Automaton (DFA)? If so, would it be possible to share it here? Thank you!
Nope, I have no idea what DFA is. And when I looked at the DFA solution I must honestly say I don't see the point. The straightforward solution works in the same time and space complexity and is much easier to come up with. I tend to stay away from weird and niche solutions like DFA or DP on this channel because they're just too confusing and literally pointless because there's always a more "common sense" alternative. If an interviewer ever fails me for not knowing those then so be it but I never found it remotely useful to bother with those sort of things. 😂
Haha thanks for the feedback but it's too late to change the channel name. Also the captions are autogenerated by Google. Doing them by hand would be a massive time sink and it's not worth it given there's no real upside and the cost in time terms is massive. I actually believe that Leetcode Contests are a total waste of time and people shouldn't bother with them. Though you've just given me a great idea for a video so stay tuned for that and I'll explain why 😁
Your channel is super underrated
Thanks! Your support is much appreciated
Excellent explanation I honestly was dreading to do this for the past few days. As soon as I watched your video I got it. Wish I had watched it sooner.
Yea it’s relatively intuitive to solve, just a bit tricky to code up because of the volume of code here
Huh! I was almost lost while reading the leetcode solution, but I know you can give me hope. Would love to see solutions for more top-ranked questions from you. Thank you.
can you explain more about why we still need to pop when cur_char is a letter? is it due to a greedy way of thinking that even if the letter pops, if the res is valid (with/without letter) the max length should always include the letter?
same doubt
Its because curr_res is pointing to a reference instead of a new array. So we always need to pop() in order to leave the array at its before state for the next recursive call. We can remove the need for pop by inputting a new array into every function call but this take more space since we will have multiple copies of the array for each call stack.
amazing solution! LOVE UR CHANNEL
Is there any benefit to DFS / Backtracking over BFS for this problem? The BFS code is much simpler and more intuitive than the DFS.
Great explanation! Thank you!😊
Thanks for posting the leetcode solutions. I really enjoy your channel. I have a meta interview coming up for a DE position, is python technical coding interview for DE easier than that for SWE? I find python medium in leetcode still pretty hard unless I have solved the exact question before.
Awesome explanation :) it doesnt seem to be hard after all! Can you do the most asked meta question
2060 Check if an Original String Exists Given Two Encoded Strings
Yea it really isn’t. But I guess you need to see the solution once and then it’s easy.
I’ve had a lot of people request 2060… it’s quite difficult and I’m not quite sure how to solve it. Need to research it more but I wouldn’t worry because Meta doesn’t ask these sorts of really hard questions normally
:) its similar to Subset problem which is also a backtracking. Just including and excluding the current digit to form a subset. Hence said it wasn’t hard after all
here y we need self res,self, Longest string anywhy nested function can access those
wy do we need to pop alphabet char please explain
You need to do backtracking to understand that. Notice we only pop when we added to cur_res? Thats what backtracking does. When we go back up the tree we need to pop what we had added.
consider "(a)".
you start by including and not including the first "(" .
1. Let's say you start with including it - so you string becomes "(" now.
2. in the next step you include "a" , which makes it "(a". Now, here if you don't pop "a", when you go back to step1 and execute pop (hoping for "(" to pop), you are actually popping "a" instead.
How good someone need to be to pull off such a complicated solution in 20 minutes?
See the question before and basically have the solution memorised. It's just part of the LC game unfortunately
how checking the count gives us valid ans ? ()())( -> for this count is same
when you encounter the ) in ()()')'( for the first time... you dont take ) because left_count == right_count, (In order to consider ) the left_count < right_count. The result for that will be ()()
Thank you for the great explanation. Have you ever solved question 65 using Deterministic Finite Automaton (DFA)? If so, would it be possible to share it here? Thank you!
Nope, I have no idea what DFA is. And when I looked at the DFA solution I must honestly say I don't see the point. The straightforward solution works in the same time and space complexity and is much easier to come up with.
I tend to stay away from weird and niche solutions like DFA or DP on this channel because they're just too confusing and literally pointless because there's always a more "common sense" alternative. If an interviewer ever fails me for not knowing those then so be it but I never found it remotely useful to bother with those sort of things. 😂
Thank you!
Thank you very much
Thank you so much!😊🙏🏼
No problem!
suggestions change ur channel name , and give proper captions. do leetcode contest problems -> ur channel will grow
Haha thanks for the feedback but it's too late to change the channel name. Also the captions are autogenerated by Google. Doing them by hand would be a massive time sink and it's not worth it given there's no real upside and the cost in time terms is massive.
I actually believe that Leetcode Contests are a total waste of time and people shouldn't bother with them. Though you've just given me a great idea for a video so stay tuned for that and I'll explain why 😁
@@crackfaang understood by the way thank u
how are you supposed to dry run this in 5 minutes lol
also when i open www.youtube.com/@crackingfaang9468 . it is showing 404
Thats just bad python