Back to Browse

2196. Create Binary Tree From Descriptions Leetcode Editorial || Breadth First Search || #leetcode

143 views
Jul 15, 2024
33:14

Complete Playlist: https://www.youtube.com/playlist?list=PLfdTvLFsiAwWzvcjeoNQs657sSAEi9Du_ Leetcode Problem Link: https://leetcode.com/problems/create-binary-tree-from-descriptions/ Code: https://leetcode.com/problems/create-binary-tree-from-descriptions/solutions/5478139/c-breadth-first-approach-best-ever-video-solution/ Similar Problems: 1) Convert Sorted List to Binary Search Tree: https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/ 2) Number Of Ways To Reconstruct A Tree: https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree/ Problem Description: You are given a 2D integer array descriptions where descriptions[i] = [parenti, childi, isLefti] indicates that parenti is the parent of childi in a binary tree of unique values. Furthermore, If isLefti == 1, then childi is the left child of parenti. If isLefti == 0, then childi is the right child of parenti. Construct the binary tree described by descriptions and return its root. The test cases will be generated such that the binary tree is valid. Input: descriptions = [[20,15,1],[20,17,0],[50,20,1],[50,80,0],[80,19,1]] Output: [50,20,80,15,17,19] Explanation: The root node is the node with value 50 since it has no parent. The resulting binary tree is shown in the diagram. Social Handles: LinkedIn: https://www.linkedin.com/in/srajan-agrawal-98459321a/ GitHub: https://github.com/SrajanAgrawal/ Search Using: 2196 Create Binary tree from descriptions leetcode create binary tree from descriptions leetcode leetcode problem of the day leetcode 2196 leetcode create binary tree from descriptions TimeStamp: 0:00 Introduction: 0:35 Problem Description: 2:21 Example 1: 5:20 Example 2: 9:07 Build the logic: 10:20 Explanation: 15:53 C++ Implementation : 26:13 Run & Submit Code: 26:57 Dry Run: 30:53 Time & Space Complexity: 32:55 Conclusion & Next Steps:

Download

1 formats

Video Formats

360pmp441.5 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

2196. Create Binary Tree From Descriptions Leetcode Editorial || Breadth First Search || #leetcode | NatokHD