Provide Best Programming Tutorials

## 145. Binary Tree Postorder Traversal

Question Given a binary tree, return the postorder traversal of its nodes' values. Example: Input:  [1,null,2,3] 1 \ 2 / 3 Output:  [3,2,1] Follow up: Recursive solution is trivial, could you do it…

## 96. Unique Binary Search Trees

Question Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n = 3, there are a total of 5 unique…

## 92. Reverse Linked List II

Question Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2 , n = 4 Output: 1->4->3->2->5->NULL Solution /** *…

## 226. Invert Binary Tree

Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9…

## 429. N-ary Tree Level Order Traversal

Question Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary tree:     We should…

## 106. Construct Binary Tree from Inorder and Postorder Traversal

Questioin Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given inorder = [9,3,15,20,7]…

## 105. Construct Binary Tree from Preorder and Inorder Traversal

Question Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given preorder = [3,9,20,15,7]…

## 199. Binary Tree Right Side View

Question Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example: Input:  [1,2,3,null,5,null,4] Output:…

## 107. Binary Tree Level Order Traversal II

Question 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). For example: Given binary tree [3,9,20,null,null,15,7],…

## 617. Merge Two Binary Trees

Question Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are…