Leetcode 0623. Add One Row to Tree

Posted on Tue 05 November 2024 in Leetcode • Tagged with binary-tree-manipulation, dfs

Question Link : https://leetcode.com/problems/add-one-row-to-tree/

Difficulty: Medium

Premium: False

Question

Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule …


Continue reading

Leetcode 0106. Construct Binary Tree from Inorder and Postorder Traversal

Posted on Wed 15 March 2023 in Leetcode • Tagged with binary-tree-manipulation

Question Link : https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/

Difficulty: Medium

Premium: False

Question

Given two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the same tree, construct and return the binary tree.   Example 1:

Input: inorder = [9 …


Continue reading

Leetcode 0226. Invert Binary Tree

Posted on Fri 28 October 2022 in Leetcode • Tagged with binary-tree-manipulation

Question Link : https://leetcode.com/problems/invert-binary-tree/

Difficulty: Easy

Question

Given the root of a binary tree, invert the tree, and return its root.   Example 1:

Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1]

Example 2:

Input: root = [2,1,3 …


Continue reading