Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2], The longes... Read More
posted @ 2014-07-30 23:23 Xylophone Views(187) Comments(0) Diggs(0)
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example: Given the below binary tree, 1 ... Read More
posted @ 2014-07-30 18:16 Xylophone Views(126) Comments(0) Diggs(0)
Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function... Read More
posted @ 2014-07-30 11:56 Xylophone Views(80) Comments(0) Diggs(0)
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target valu... Read More
posted @ 2014-07-30 11:50 Xylophone Views(118) Comments(0) Diggs(0)
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 endpo... Read More
posted @ 2014-07-30 11:20 Xylophone Views(128) Comments(0) Diggs(0)
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which... Read More
posted @ 2014-07-30 09:45 Xylophone Views(137) Comments(0) Diggs(0)
DFS(Depth First Search) 深度优先搜索BFS (Breadth First Search)宽度优先搜索在算法中常用这两种方法。1) DFS考虑用“递归”实现和用 “栈”实现两种方法,因为对于大型问题搜索深度比较深,如果用递归实现的话,栈空间占用比较多,递归调用需要的额外时间也比... Read More
posted @ 2014-07-30 09:27 Xylophone Views(198) Comments(0) Diggs(0)
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded ... Read More
posted @ 2014-07-30 09:20 Xylophone Views(237) Comments(0) Diggs(0)