Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree.Given a unsorted array with integers, find the median of it.
Given a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in the binary search tree, do nothing. You should keep the tree still a binary search tree after removal.
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.
Problem Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example Given the below binary tree: {代码...} return 6. Note 调用helper函数更新路径和的最大值res,而helper函数本身需要递归,返回的是单边路径和single。这里需要注意:对于拱形路径和arch,从左...
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatic...
After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, the security system ...