上一页 1 ··· 5 6 7 8 9 10 11 下一页
摘要: A message containing letters fromA-Zis 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 cou 阅读全文
posted @ 2013-06-11 12:45 一只会思考的猪 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note:Recursive solution is trivial, could you do it iteratively?/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; ... 阅读全文
posted @ 2013-06-06 22:17 一只会思考的猪 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of the two partitions.For example,Given1->4->3->2->5->2andx= 3,return1->2->2->4->3- 阅读全文
posted @ 2013-06-04 18:44 一只会思考的猪 阅读(254) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest valid parentheses substring is"()", which has length = 2.Another example is")()())", where the longest 阅读全文
posted @ 2013-06-04 16:29 一只会思考的猪 阅读(276) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int reverse(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function int c = x; int buffer[512]; int i = 0; x = abs(x); while(x){ int a = x%10; buffer[i++] = a; ... 阅读全文
posted @ 2013-06-01 23:58 一只会思考的猪 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 没有资格。事实上很差劲 阅读全文
posted @ 2013-04-10 00:11 一只会思考的猪 阅读(103) 评论(0) 推荐(0) 编辑
摘要: You are given a 2-D array with same number of rows and columns. You have to determine the longest snake in the array. The property to find the snake is the difference between the adjacent(left, right, up or down) should be either 1 or -1. If there are more than one snakes with maximum length, the ou 阅读全文
posted @ 2013-04-07 00:20 一只会思考的猪 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 如何做一个QC,从原理上解释清楚,并且能够又快又好呢,google Novig给了一个简短的阐述,回头要看看腾讯的怎么做的了。http://norvig.com/spell-correct.html 阅读全文
posted @ 2013-03-24 23:14 一只会思考的猪 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 1、利用(0,1)之间的随机数生成器rand()生成(a,b)之间的随机数:(b-a)/rand() + a;2、利用(0,a)之间的随机数生成器rand()生成(0,b)之间的随机数:只要a和b之间没有倍数关系3、求一个string的最长回文前缀子串:用逆序的数组作为patten,用KMP算法求最后停在哪里。4、假设random(0,1)输出结果是50%的0和50%的1 ,要求利用random(0,1)随机在[a,b]内产生一个数。题目2的解答(答案来自水木精华区):已知 所给的随机数发生器的样本空间为 [0, M),即 [0, RAND_MAX]; 结果的样本空间大小 N,即 diviso 阅读全文
posted @ 2013-03-07 14:56 一只会思考的猪 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 大部分的内容来自http://hi.baidu.com/yangchenhao/item/3d0c631200f0b1e75e53b1a7,少部分的内容是自己添加的首先介绍一下这个数据结构的定义,YoungTableau有一个m*n的矩阵,让后有一数组a[k],其中k<=m*n,然后把a[k]中的数填入m*n的矩阵中,填充规则为(如图1-1):1.每一行每一列都严格单调递增(有其他的版本是递减,其原理相同)。2.如果将a[k]中的数填完后,矩阵中仍有空间,则填入∞。图1-1则现在讨论,这个数据结构的几种操作,而在这些操作中,我们会发现堆排序的影子,并且这些操作具有很好的时间复杂度。条件: 阅读全文
posted @ 2013-03-05 09:15 一只会思考的猪 阅读(805) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 下一页