이진트리

    [LeetCode] 22. Generate Parentheses

    [LeetCode] 22. Generate Parentheses

    22. Generate Parentheses Medium Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Example 2: Input: n = 1 Output: ["()"] Constraints: 1 cnt2: dfs(cnt1, cnt2 + 1, temp + ')') dfs(0, 0, '') return res

    [LeetCode] 623. Add One Row to Tree

    [LeetCode] 623. Add One Row to Tree

    623. Add One Row to Tree Medium 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..