Adding one row to a Binary Tree
Love tree problems, once you get it right, there are usually very few corner cases (other than the d=1, which was mentioned in the problem description anyways). Here it is, and code is down below. Song that goes along well with this problem: https://www.youtube.com/watch?v=7HHBFkdHyRU&list=PL9LM05lDUoXqVDYM5MIM4owPiYLCm_Ucm&index=385 Cheers, ACC. https://leetcode.com/problems/add-one-row-to-tree/ 623. Add One Row to Tree Medium 378 119 Add to List Share Given the root of a binary tree, then value v and depth d , you need to add a row of nodes with value v at the given depth d . The root node is at depth 1. The adding rule is: given a positive integer depth d , for each NOT null tree nodes N in depth d-1 , create two tree nodes with value v as N's left subtree root and right subtree root. And N's original left subtree should be the left subtree of...