shlogg · Early preview
Md Ariful Haque @mah-shamim

Add One Row To Binary Tree In Depth-First Search

Add one row to binary tree at specified depth using DFS or BFS traversal and insert new nodes with value val as left and right children of each node.

623. Add One Row to Tree
Difficulty: Medium
Topics: Tree, Depth-First Search, Breadth-First Search, Binary Tree
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 is:

Given the integer depth, for each not null tree node cur at the depth depth - 1, create two tree nodes with value val as cur's left subtree root and right subtree root.
cur's original left subtree should be the left subtree of the new left subtree root.
cur's original right subtree should be the right s...