Path Sum III | leetcode 437 | Hindi

  Рет қаралды 25,282

Codebix

Codebix

Күн бұрын

subarray sum equals k :- • Subarray Sum Equals K ...
liked this video? Click here / @codebix1096
join our Facebook group :- / 258049468776636
problem :-leetcode.com/p...
code :- github.com/luc...

Пікірлер: 77
@mayankguptacse5904
@mayankguptacse5904 3 жыл бұрын
Every KZbin video explained the O(n^2) approach but this one showed the O(n) approach as well in a superb intuitive way. Well done.
@kirtimanmishra8097
@kirtimanmishra8097 4 жыл бұрын
Awesome sir!! The backtracking part helped me.
@codebix1096
@codebix1096 4 жыл бұрын
Great please share this channel with your friends
@vibhanshusharma9143
@vibhanshusharma9143 8 ай бұрын
can some body help me why this is wrong public: int ans = 0; unordered_map freq; int curr_sum = 0; void solve(TreeNode* root, int target) { if (root == nullptr) return; curr_sum += root->val; if (freq.find(curr_sum - target) != freq.end()) { ans+=freq[curr_sum-target]; } freq[curr_sum]++; solve(root->left, target); solve(root->right, target); freq.erase(curr_sum); curr_sum -= root->val; return; } int pathSum(TreeNode* root, int targetSum) { freq[0]++; solve(root, targetSum); return ans; } for [1,-2,-3,1,3,-2,null,-1] target =2; output is 0 but ans is 1;
@pushkardureja6863
@pushkardureja6863 4 жыл бұрын
well explained ..... you gained a sub :)
@utkarshsharma1185
@utkarshsharma1185 Жыл бұрын
thanks for the amazing explanation sir
@palakjain2505
@palakjain2505 2 жыл бұрын
shouldn't we backtrack (i.e., remove sum from hashmap) before making the right subtree call?
@AyushiSharmaDSA
@AyushiSharmaDSA 4 жыл бұрын
Thank you so much for explaining....Helped a lot :)
@codebix1096
@codebix1096 4 жыл бұрын
You are welcome please share this channel with your friends
@Saurabh-gg9lv
@Saurabh-gg9lv 2 жыл бұрын
👀🤭
@vishalverma2986
@vishalverma2986 Жыл бұрын
i was reading comment and found u,i also follow your channel.but when i search a particular question i always prefer codebix first and then you.both r great teacher.helps me alot.
@urs_Gaurav_drdz
@urs_Gaurav_drdz 7 ай бұрын
Optimise approach submit nhi ho rhi Wrong answer aa rh hai😢
@himanshuchugh1186
@himanshuchugh1186 4 жыл бұрын
All the very best for your youtube channel brother!! keep growing...
@codebix1096
@codebix1096 4 жыл бұрын
Thank you so much 🙂
@rajgupta5158
@rajgupta5158 4 жыл бұрын
Awesome explanation sir, please make more such video.
@rahul_singh_rajput3292
@rahul_singh_rajput3292 2 жыл бұрын
sir your explanations are always OP 🔥..
@shantanukumar4081
@shantanukumar4081 2 жыл бұрын
thanks bhaiya amazing solution
@SURAJOMAR-q8b
@SURAJOMAR-q8b 2 ай бұрын
lekin bhai wrong anser aa rha tha n^2 mein
@chrisy.703
@chrisy.703 2 жыл бұрын
hard to understand ur english... accent is too heavy...
@rhythmbhandari1700
@rhythmbhandari1700 2 жыл бұрын
Truu
@yashsahay1096
@yashsahay1096 2 жыл бұрын
Most underrated coding channel I have ever encountered. Really intuitive approach!
@ankitmilmile6513
@ankitmilmile6513 Жыл бұрын
your brute force solution failing this test case [1000000000,1000000000,null,294967296,null,1000000000,null,1000000000,null,1000000000] can you please debug why?
@rashvikumari3782
@rashvikumari3782 5 ай бұрын
even O(n) solution is failing for same test case. I changed data type of sum from int to long as sum goes over the max range of int
@financewithsom485
@financewithsom485 4 жыл бұрын
you channel will grow exponentially.doing great job
@codebix1096
@codebix1096 4 жыл бұрын
hope so SOMMAN EDU share vare kro tum channel tbhi to grow karega
@pubglittlepro9585
@pubglittlepro9585 Жыл бұрын
ye solution completly sahi nahi hai ... leetcode pr 127/128 passed hai but ek test case failed hai jisse submit nahi ho pa rha hai. just trying to solve..🙃
@sanchit9450
@sanchit9450 7 ай бұрын
use long instead of Integer
@kueen3032
@kueen3032 4 жыл бұрын
Hey, what software do you use for explaining?
@codebix1096
@codebix1096 4 жыл бұрын
Openboard
@harshitsaxena3064
@harshitsaxena3064 Жыл бұрын
Just a simple change in code which will pass all the test cases on leetcode: class Solution { Map visited=new HashMap(); int count=0; public int pathSum(TreeNode root, int targetSum) { visited.put(0L,1); helper(root,targetSum,0); return count; } public void helper(TreeNode root,long targetSum,long currentSum){ if(root==null) return; currentSum+=root.val; if(visited.containsKey(currentSum-targetSum)){ count=count+(int)visited.get(currentSum-targetSum); } visited.put(currentSum,visited.getOrDefault(currentSum,0)+1); helper(root.left,targetSum,currentSum); helper(root.right,targetSum,currentSum); visited.put(currentSum,visited.get(currentSum)-1); } }
@ovipoddar2723
@ovipoddar2723 4 жыл бұрын
Your r great sir..Your way of explanation is outstanding..
@abhinaygupta
@abhinaygupta 4 жыл бұрын
The second solution is great.
@codebix1096
@codebix1096 4 жыл бұрын
please share this channel with your friends
@KamleshSharma-si2rq
@KamleshSharma-si2rq 4 жыл бұрын
wo nei karoge to ispe palla nei karega choro meh kehna chor deta hu.. This is my python solution and Thanks for the awesome explaination. ```python def pathSum(self, root: TreeNode, sum: int) -> int: self.total=0 if(root is None): return 0 d={0:1} self.findpathSum(root,0,sum,d) return self.total def findpathSum(self,root,s,target,d): if root is None: return s+=root.val if(s-target in d): self.total+=d[s-target] if(s in d): d[s]+=1 else: d[s]=1 self.findpathSum(root.left,s,target,d) self.findpathSum(root.right,s,target,d) d[s]=-1 ```
@Day-je4um
@Day-je4um 4 жыл бұрын
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left, TreeNode right) { * this.val = val; * this.left = left; * this.right = right; * } * } */ class Solution { int flag =0; ArrayList list = new ArrayList(); public int pathSum(TreeNode root, int sum) { getSum(root,sum); return flag; } public void getSum(TreeNode root , int sum){ if(root == null){ return; } list.add(root.val); getSum(root.left,sum); getSum(root.right,sum); int temp=0; for(int i=list.size()-1;i>=0;i--){ temp+=list.get(i); if(temp==sum) flag++; list.remove(list.size()-1); } } }
@baaznotapro5479
@baaznotapro5479 4 жыл бұрын
Should i use dp or graph for traveling salesman problem
@saunaknandi1814
@saunaknandi1814 2 жыл бұрын
what should be the time complexity??
@hemantkumar2585
@hemantkumar2585 11 ай бұрын
the way of teaching is awesome 👌👌👌👌👌👌
@decodingParinda
@decodingParinda 4 жыл бұрын
clean and crisp explanation :) Thank for it
@codebix1096
@codebix1096 4 жыл бұрын
You're welcome!
@shubhamkumargupta3478
@shubhamkumargupta3478 3 жыл бұрын
I was confused on a different question related to this, if I have a binary tree and I have 2 nodes given and I have to find the path sum of these two nodes , no maximum or target sum is there just I have to get path sum of two nodes, how to do that?
@abhishektanwar7902
@abhishektanwar7902 4 жыл бұрын
What if we have to print those path whose sum is equals 8.Can you provide the code for that. Btw nice explanation.
@prasannamalatesha3887
@prasannamalatesha3887 Жыл бұрын
Great video, nicely explained
@raghavjha8040
@raghavjha8040 2 жыл бұрын
why we have to do backtrack ?
@kzy747
@kzy747 2 жыл бұрын
boi you saved my career
@vaarigupta6332
@vaarigupta6332 Жыл бұрын
Nice and clear explanation
@farazjawaid2982
@farazjawaid2982 Жыл бұрын
what an explanation sir
@akashkumardas6521
@akashkumardas6521 3 жыл бұрын
sir simple sa code nah h, isko samajh toh google me apply karoonga sidha..
@aryans_space
@aryans_space Жыл бұрын
excellent solution sir
@sarthakyadav9148
@sarthakyadav9148 3 жыл бұрын
great explanation.
@codebix1096
@codebix1096 3 жыл бұрын
Glad you liked it Follow our linkedin page for regular updates www.linkedin.com/company/codebix/?viewAsMember=true
@leetcodebegineer6704
@leetcodebegineer6704 2 жыл бұрын
saii solution
@letsconclude8023
@letsconclude8023 Жыл бұрын
O(n) wala approach badhiya tha guru.
@trevorPhillips284
@trevorPhillips284 3 жыл бұрын
Thanks for the hint.
@kushal800
@kushal800 Жыл бұрын
Great video
@rishiwork5922
@rishiwork5922 2 жыл бұрын
awesome explanation
@kartiksoni
@kartiksoni 2 жыл бұрын
you are a legend bro !!!
@suvamgupta2914
@suvamgupta2914 2 жыл бұрын
Just Awesome ❤️
@vadirajjahagirdar9342
@vadirajjahagirdar9342 3 жыл бұрын
Very good video!
@21pranavsingh
@21pranavsingh 2 жыл бұрын
bhtubhut shukriya ;>
@singerpranavmodi
@singerpranavmodi 4 жыл бұрын
bhai yar gazab ho !!! Brilliant explanation.. EK request.. Please make video on longest increasing subsequence. Both O(n^2) and O(nlogn) approach.
@codebix1096
@codebix1096 4 жыл бұрын
Thanks will try when i continue DP playlist
@abhishekk1231
@abhishekk1231 2 жыл бұрын
Helpful!
@akshaygill4692
@akshaygill4692 Жыл бұрын
Thanku ❤
@aamirjamal6833
@aamirjamal6833 3 жыл бұрын
Wow! First video and Subscribed!
@codebix1096
@codebix1096 3 жыл бұрын
Welcome aboard! Thank you. Follow our linkedin page for regular updates www.linkedin.com/company/codebix/?viewAsMember=true
@umangsomtiya5826
@umangsomtiya5826 4 жыл бұрын
i stop in the mid of video and come here first to say !!!great explaination
@codebix1096
@codebix1096 4 жыл бұрын
Thanks :)
@bitrish34
@bitrish34 3 жыл бұрын
💥💥🔥
@ragingpahadi
@ragingpahadi 4 жыл бұрын
Great explanation brother !
@codebix1096
@codebix1096 4 жыл бұрын
Thanks 🙂
@harshalgarg1149
@harshalgarg1149 4 жыл бұрын
Great Explanation.
@codebix1096
@codebix1096 4 жыл бұрын
Thanks :)
Path Sum III | LeetCode 437 | Medium
25:01
Code And Coffee
Рет қаралды 13 М.
Path Sum iii | LeetCode 437 | C++, Java, Python
15:02
Knowledge Center
Рет қаралды 38 М.
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 4,4 МЛН
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 30 МЛН
Amazing Parenting Hacks! 👶✨ #ParentingTips #LifeHacks
00:18
Snack Chat
Рет қаралды 23 МЛН
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,8 МЛН
Subarray Sum Equals K | leetcode 560 | Hindi
13:11
Codebix
Рет қаралды 15 М.
Binary tree maximum path sum | Leetcode #124
15:23
Techdose
Рет қаралды 55 М.
All Nodes Distance K in Binary Tree | leetcode 863 | Hindi
15:46
LeetCode 437. Path Sum III  [Solution + Code Explained ]
10:38
jayati tiwari
Рет қаралды 21 М.
Knight Probability in Chessboard | leetcode 688 | Hindi
16:17
Implement Trie (Prefix Tree) | leetcode 208 | Hindi
22:06
Codebix
Рет қаралды 7 М.
Rat in a maze | Backtracking | Hindi
18:18
Codebix
Рет қаралды 7 М.
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 4,4 МЛН