Expression Add Operators | Leetcode 282 | Live coding session 🔥🔥🔥

  Рет қаралды 9,971

Coding Decoded

Coding Decoded

Күн бұрын

Пікірлер: 30
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 3 жыл бұрын
Million dollar wisdom : kzbin.info/www/bejne/a17Ll2iHet9oibs Backtracking Playlist: kzbin.info/aero/PLEI-q7w3s9gQtquxHpuFHXHO2OdgC0GyU
@sayantandey4708
@sayantandey4708 Ай бұрын
Strivers A2Z recursion done 😌😌 Thank you very much sir.
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja Ай бұрын
Not try this : github.com/Sunchit/Coding-Decoded/tree/master/SDE%20Revision%20Sheet
@guptagaurav916
@guptagaurav916 3 жыл бұрын
Was waiting for this video. Thanks!
@stith_pragya
@stith_pragya Жыл бұрын
Thank You So Much For this wonderful video......🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@anujagarwal3706
@anujagarwal3706 Жыл бұрын
u have simply read the code. please explain recursion questions with recursive tree. Thanx.
@kouroshbaghaei382
@kouroshbaghaei382 9 ай бұрын
This video was excellent! I liked your solution! 👌
@PaulFitone
@PaulFitone 2 жыл бұрын
Hi @sunchit. Explanation was quiet good but you forgot to tell why you used a for loop for recursion bcoz in given examples it's not given that you can take two or more substring at once. I also thought that we only take a char at a time but this is not case so, you can modify or upload new video with mentioning those examples. Bcoz as the examples are given no can can thing of a loop just simple 3 recursive call can do job. So please include that example to understand the intuition behind for loop
@The_Promised_Neverland...
@The_Promised_Neverland... 2 жыл бұрын
MAYBE A BIT EASIER C++ CODE class Solution { public: void generate(string &num, int target, int curr, vector &res, string build, long long int prevNumber, long long int currSum){ if(curr==num.size()){ if(currSum==target){ res.push_back(build); } return; } for(int len=1;len1){ continue; } long long int currNum=stoll(number); generate(num,target,curr+len,res,build+"+"+number,currNum,currSum+currNum); generate(num,target,curr+len,res,build+"-"+number,-currNum,currSum-currNum); generate(num,target,curr+len,res,build+"*"+number,currNum*prevNumber,currSum-prevNumber+currNum*prevNumber); } } vector addOperators(string num, int target) { vector res; for(int len=1;len1){ continue; } long long int currNum=stoll(number); generate(num,target,len,res,number,currNum,currNum); } return res; } };
@ameynaik2743
@ameynaik2743 3 жыл бұрын
Also for '*' the prevNum argument in DFS is prevNum*currNum... very critical!
@wintersol9921
@wintersol9921 3 жыл бұрын
What is the purpose of: Line 14 - > if (j > i && s.charAt(i) == '0') break; // Skip leading zero number Why do we do j > i. What happens if j == i? Can someone explain it clearly please.
@harshmantri3614
@harshmantri3614 3 жыл бұрын
So suppose the character at ith position is 0… ex string 3012 and we are at i == 1 When we loop for j we select the substring from i to j as our current number so when j == i == 1 in this case, we are considering the current number as 0 which we can operate with. When j becomes 2 we consider 01 as the current number and 01 is not a valid two digit number so we break because any substring after the index that has 0 will have leading 0s and is not valid. Simply put, we do that thing to avoid considering substrings starting with 0. But 0 itself as a substring is fine. Thus we break for j>i and only process the ith character when the ith character is 0.
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 3 жыл бұрын
@@harshmantri3614 thanks for taking up the questions
@wintersol9921
@wintersol9921 3 жыл бұрын
@@harshmantri3614 Thanks a lot.
@shrimpo6416
@shrimpo6416 2 жыл бұрын
Thx for explaining so well! I understand it right away
@anukooljaiswal8626
@anukooljaiswal8626 2 жыл бұрын
nice explanation..
@mrrishiraj88
@mrrishiraj88 3 жыл бұрын
Thanks
@coder1015
@coder1015 3 жыл бұрын
Bro in the dfs call of multiplication operator why are we updating the prevnum to prevnum*currnum instead of currnum pls explain
@harshmantri3614
@harshmantri3614 3 жыл бұрын
This handles the case where we have to do consecutive multiplications… In that case, we keep track of the value of all the multiplications done so far in the prevnum, because we have to rewind the value to the last operation we did that was not a multiplication.
@manthanjoshi6110
@manthanjoshi6110 3 жыл бұрын
Time complexity is 3^N right?? Where n is size of string of digits
@fardeenmeeran3909
@fardeenmeeran3909 3 жыл бұрын
I was under the impression that it might be (3^n * n ) since there is the for loop as well
@sushilrawat4901
@sushilrawat4901 3 жыл бұрын
Can anyone tell me multiplication case . why " -prevNum + prevNum *currNum "
@RajasthaniLadka
@RajasthaniLadka 3 жыл бұрын
On line number 14 you discard zero then how this test case :- num="00" working??
@wintersol9921
@wintersol9921 3 жыл бұрын
I asked the same question, there is a good explanation under my comment (someone commented a good explanation.) The simple answer is the if statement on line 14 eliminates "00" in the output. But it considers "0+0", "0-0", "0*0" because of the statement j>i. "j>i" helps to take 0 as a single number, but eliminates it from the recursion if it is a leading zero. Since 00 is the same as 0 and we don't need it in the output.
@krishnakshirsagar4570
@krishnakshirsagar4570 2 жыл бұрын
what if / is there with +,-,*
@updates8455
@updates8455 13 күн бұрын
bss code likh ke bhaag gya\
@Coolharshit149
@Coolharshit149 3 жыл бұрын
Why it is break not continue in zero case ?
@rishabhpal8236
@rishabhpal8236 3 жыл бұрын
was wondering the same. Can someone explain?
@rishabhpal8236
@rishabhpal8236 3 жыл бұрын
after some thought, the zero if it comes in the middle of the string cannot exist alone as it won't change the value of resSoFar and should atleast be a two digit number.
@subee128
@subee128 10 ай бұрын
Thanks
Distinct Subsequences | Leetcode 115 | Live coding session
20:44
Coding Decoded
Рет қаралды 2,6 М.
EXPRESSION ADD OPERATORS | LEETCODE # 282 | PYTHON SOLUTION
24:05
Cracking FAANG
Рет қаралды 7 М.
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 23 МЛН
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
Leetcode 282: Expression Add Operators | Master Backtracking | Intuition and Approach
32:20
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 404 М.
Design Twitter - Leetcode 355 - Python
22:47
NeetCode
Рет қаралды 92 М.
Problem of The Day: 25/05/2023 | Expression Add Operators | Abhinav Awasthi
25:50
GeeksforGeeks Practice
Рет қаралды 2,8 М.
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 124 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 674 М.
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 23 МЛН