Problem
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Example
given n = 3, a solution set is:
1 | [ |
Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
Given binary tree [3,9,20,null,null,15,7]
,
1 | 3 |
return its minimum depth = 2.
A leaf is a node with no children.
Given two binary trees, write a function to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical and the nodes have the same value.
1 | Input: 1 1 |
1 | Input: 1 1 |
1 | Input: 1 1 |
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as:
a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
[3,9,20,null,null,15,7]
:1 | 3 |
Return true.
Given the following tree [1,2,2,3,3,null,null,4,4]
:
1 | 1 |
Return false.
Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).
Given binary tree [3,9,20,null,null,15,7]
,
1 | 3 |
return its bottom-up level order traversal as:
1 | [ |
Given a non-empty, singly linked list with head node head
, return a middle node of linked list.
If there are two middle nodes, return the second middle node.
1 | Input: [1,2,3,4,5] |