2013年5月3日

摘要: Pre-definition: "median of a array"isthe right-middle-value element.if O(m+n), then Merge Sort is OK!Note: The overall run time complexity should be O(log (m+n)).Reaction: Binary-Find!Input: A[0...m-1] and B[0...n-1]Steps:get the medians "ma&mb"of array A and B;compare ma and 阅读全文
posted @ 2013-05-03 09:50 highstar88 阅读(237) 评论(0) 推荐(0) 编辑

2013年4月16日

摘要: n = 1*a + 2*b; find ways.if(a==n) b=0; way0 = C(n-0,0) = 1;if(a==n-2) b=1; way1 =C(n-1,1);if(a==n-4) b=2; way2 = C(n-2,2);...if(a==n-2*i) b=i; wayi = C(n-i,i);as, i = 0,1,..., [n/2]Fibonacci Sequencehttp://zh.wikipedia.org/wiki/%E6%96%90%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0%E5%88%97#.E5.92... 阅读全文
posted @ 2013-04-16 21:28 highstar88 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Judge Rules:1. the maximum value of left subtree < root's value2. the minimum value of right subtree > root's value3. both the left and right subtrees are meet the above conditions.4* empty tree is valid!http://www.cnblogs.com/remlostime/archive/2012/11/16/2772629.htmlC header file< 阅读全文
posted @ 2013-04-16 20:46 highstar88 阅读(96) 评论(0) 推荐(0) 编辑
摘要: palindrome - 回文alphanumeric - 字母数字Have you consider that the string might be empty? This is a good question to ask during an interview.Attention to :1. only alphanumeric chars2. ignore cases3. empty string conditionEasy!bool isalphanumeric(char c){ if(c>='A'&&c<='z' || 阅读全文
posted @ 2013-04-16 20:06 highstar88 阅读(120) 评论(0) 推荐(0) 编辑

2013年4月14日

摘要: Binary Divided Solver.Recursion.(not the tail-recursion, so cannot transform to non-recursion)Attention to: 1. overflow.(up-overflow/down-overflow). 2. input conditions: positive/negtive/precision. 阅读全文
posted @ 2013-04-14 17:30 highstar88 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Easy!Attention to the special inputs:1. one empty or two empty;2. the first node as head should be proposed individualy. 阅读全文
posted @ 2013-04-14 16:36 highstar88 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Reduction problem in compiling principle.Data Structure: stackSTL - stack: http://www.cplusplus.com/reference/stack/stack/ http://sunzhongfang22.blog.163.com/blog/static/33856090201152451347642/Solver: 1. when encounters a pre-bracket, push it to the stack; 2. when encounters a post-bracket, pop... 阅读全文
posted @ 2013-04-14 16:13 highstar88 阅读(91) 评论(0) 推荐(0) 编辑
摘要: Expand the 2Sum solver to 3Sum:for every specific a, find the other two b&c that b+c=-a.so, it can be solved in O(n^2).1. generic "find" function:iterator = find(vec.begin(), vec.end(), vecElem);if(iterator == vec.end()) cout<<"no find the vecElem in vec!"<<endl;A 阅读全文
posted @ 2013-04-14 11:48 highstar88 阅读(170) 评论(0) 推荐(0) 编辑

2013年4月13日

摘要: Consider very carefully to cover all the possible input conditions!atoi: string -> integerinput: str1. size: different C++ data type's size in different machine [list]:http://hi.baidu.com/yangyangye2008/item/ba0a35395420d2f9df222157 (default: int - 4 bytes)2. begin (' ','+',&# 阅读全文
posted @ 2013-04-13 22:23 highstar88 阅读(126) 评论(0) 推荐(0) 编辑
摘要: References——Problems List: http://leetcode.cloudfoundry.com/cplusplus: http://www.cplusplus.com 阅读全文
posted @ 2013-04-13 21:20 highstar88 阅读(158) 评论(0) 推荐(0) 编辑

导航