2014年(53)
发布时间:2014-09-06 13:50:01
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number of ways to decode it.For example,Given encoded message "12", it could be dec.........【阅读全文】
发布时间:2014-09-05 22:26:10
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7], [4,1,8,3]]The minimum path sum from top to bottom is 11 (i.e., 2&n.........【阅读全文】
发布时间:2014-09-04 22:11:36
题目一:设两个有序数组的长度均为n,求它们组成的2n长的数组的中位数。假设n为奇数,那么n/2是每个数组中位数的下标,假设1. A[n/2]>B[n/2],那么A[n/2+1]...A[n-1]都大于A[0]...A[n/2]并且大于B[0]...B[n/2],而这些数加起来有n+1个,所以A[n/2+1]...A[n-1]大于所求的中位数;同理,B[0]...B[n/2-1]小于B[n/2]...B[n-.........【阅读全文】
发布时间:2014-09-04 14:32:08
这道题也算是很经典的了,属于一个基本原理题,深刻理解了这种题,也就理解了一大堆相似的问题。分析:n对括号,那么位置0出现的括号必然是“(”,和它配对的“)”可能出现在1,3,5,。。。。2n-1的位置上,因此若假设f(2n)指的是2n个括号(n对)的所有可能合法组合的个数,以及”和位置0的左括号配对的右括号出现在位置k.........【阅读全文】