even if I solve a problem, I immediately go to see your explanation, so many of leetcode’s editorials are indecipherable (at least for me)
@tekfoonlim47455 ай бұрын
This is today's leetcode problem. Nice explanation man!
@raviyadav25525 ай бұрын
can you make a series dedicated to trees and related concepts?
@licokr5 ай бұрын
Thanks for uploading the video! It motivates me. Consistency is the key! 🔑
@adityamwagh5 ай бұрын
Hey, I think it would be a good idea to make a webextension which enables us to see this video in the leetcode tab itself!
@sathwikmadhula95275 ай бұрын
Neetcide, I request you to please solve the concurrency problems on leetcode. The leetcode numbers are 1114, 1115, 1116, 1117, 1188, 1195, 1226, 1242, 1279.
@vishaalkumaranandan28945 ай бұрын
That usage of min() was brilliant!!
@daikaji38335 ай бұрын
Today is the day. I'm tired of sitting here with this degree and being unable to use it. No more wasted potential. I am buying the 1 yr subscription right now, and I'm going all in to prepare for job hunting. Thank you for all that you do.
@MiraKumar-rm5ke5 ай бұрын
I have a question, for the input - [25, 1, 3, 1, 3, 0, 2] shouldn't the output be "bbz" and not "adz" (actual output). Your input is appreciated. thanks! @NeetCodeIO
@fancypants60625 ай бұрын
I had to figure out the same thing as you. It is because the "lexicographically smaller" does not mean that the sum of the letters (treated as numbers) is smaller; it means alphabetic order, so anything starting with a is ahead of anything starting with b, no matter what the rest of the letters are.
@sankhadip_roy5 ай бұрын
Less code but same concept class Solution: def smallestFromLeaf(self, root: Optional[TreeNode]) -> str: self.ans="{" def dfs(node, word): if not node: return word = chr(97 + node.val)+word if not node.left and not node.right: if word
@SC2Edu5 ай бұрын
I used the same approach, it made more sense in my head.
@sankhadip_roy5 ай бұрын
@@SC2Edu Yes absolutely
@MP-ny3ep5 ай бұрын
Thank you so much. This was so beautifully explained.
@mohammadmohtashim79855 ай бұрын
Man this is a good solution.
@yang58435 ай бұрын
I wrote mine a little differently class Solution { String rc = ""; public String smallestFromLeaf(TreeNode root) { dfs(root,""); return rc; } void dfs(TreeNode root, String temp) { if ( root == null ) return; temp = (char) ('a'+root.val)+temp; if (root.left == null && root.right == null ) { if ( rc.equals("") || temp.compareTo(rc) < 0 ) rc = temp; return; } dfs(root.left,temp); dfs(root.right,temp); } }
@og_23yg545 ай бұрын
dump way use E2AV way 77% faster
@rafaelhung18125 ай бұрын
thank you for your consistency
@krateskim41695 ай бұрын
Thank you so much
@NursultanBegaliev5 ай бұрын
Thank you! 👍👍
@chrischika70265 ай бұрын
im pretty sure you dont need the if not root: return part because you never have node
@PedanticAnswerSeeker5 ай бұрын
table = [chr(ord('a')+i) for i in range(26)] def helper(root, nowStr): if root==None: return nowStr if root.left==None: return helper(root.right, table[root.val]+nowStr) if root.right==None: return helper(root.left, table[root.val]+nowStr) return min(helper(root.left, table[root.val]+nowStr), helper(root.right, table[root.val]+nowStr)) return helper(root, '')
@billyrobins65155 ай бұрын
Nice one, good to know, that I am the first here
@chien-yuyeh93865 ай бұрын
🎉🎉
@dss9635 ай бұрын
Now tell me which is smaller in this according to the problem, "jd" or "hud"
@zweitekonto96545 ай бұрын
Greedy would work when we were reading from top down.
@3ombieautopilot5 ай бұрын
The question is a little bit too easy for the Medium level.
@VinayKumar-jf3ue5 ай бұрын
you're code used beat 80-90% of users
@SC2Edu5 ай бұрын
Why not just check which string is smaller when we are at a leaf node?
@jayrathod92715 ай бұрын
On the first leaf node, we don't have information about other leaf nodes
@I.II..III...IIIII.....5 ай бұрын
Yeah, that's what I did. I initiated my minimumString as "", and then I just checked if minimumString == "" or currentString < minimumString then minimumString = currentString