上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 21 下一页
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter ca... Read More
posted @ 2014-07-31 17:43 Xylophone Views(189) Comments(0) Diggs(0)
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)
递归特点:简而言之,递归就是应用程序调用自身。所以,存在预期收敛,才能使用递归(因为不能无限期递归调用下去)。优点:程序看着比较简单,比较容易实现。缺点:递归要占用额外的栈空间,如果递归的深度比较大,那么占用的栈比较多,而且调用函数的时间也比较多,时空性都不好。所以选择递归要考虑好处和缺点之间的权衡... Read More
posted @ 2014-07-29 20:31 Xylophone Views(1076) Comments(0) Diggs(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 21 下一页