Container with Most Water

2017-01-15
阅读 1 分钟
1.6k
Container with Most Water Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the cont...

Trapping water

2017-01-15
阅读 2 分钟
1.4k
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

Intersection of 2 lists

2017-01-11
阅读 3 分钟
1.4k
Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.

Find the Connected Component in the Undirected Graph

2017-01-05
阅读 2 分钟
2.2k
Find the number connected component in the undirected graph. Each node in the graph contains a label and a list of its neighbors. (a connected component (or just component) of an undirected graph is a subgraph in which any two vertices are connected to each other by paths, and which is connected ...

Clone Graph

2017-01-05
阅读 3 分钟
1.8k
题目:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.

Search Range in BST

2017-01-04
阅读 2 分钟
1.4k
Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print all x such that k1<=x<=k2 and x is a key of given BST. Return all the keys in ascending order.

tweaked identical binary tree

2017-01-04
阅读 2 分钟
2.3k
原题检查两棵二叉树是否在经过若干次扭转后可以等价。扭转的定义是,交换任意节点的左右子树。等价的定义是,两棵二叉树必须为相同的结构,并且对应位置上的节点的值要相等。注意:你可以假设二叉树中不会有重复的节点值。样例

LCA---Lowest common ancestor

2017-01-03
阅读 2 分钟
1.4k
在root为根的二叉树中找A,B的LCA: 如果找到了就返回这个LCA 如果只碰到A,就返回A 如果只碰到B,就返回B 如果都没有,就返回null

Binary Tree Maximum Path Sum

2017-01-02
阅读 2 分钟
1.5k
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. {代码...}

Array---Remove Duplicates from Sorted Array——移除排序数组中重复元素

2017-01-01
阅读 3 分钟
1.5k
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.