2015年3月8日
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文
posted @ 2015-03-08 20:16 lichen782 阅读(282) 评论(0) 推荐(0) 编辑
  2015年2月27日
摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2015-02-27 21:29 lichen782 阅读(1967) 评论(0) 推荐(0) 编辑
  2015年2月25日
摘要: There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2015-02-25 22:12 lichen782 阅读(350) 评论(0) 推荐(0) 编辑
  2015年2月24日
摘要: Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs... 阅读全文
posted @ 2015-02-24 13:06 lichen782 阅读(361) 评论(0) 推荐(0) 编辑
  2015年2月18日
摘要: Best Time to Buy and Sell Stock IIISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the... 阅读全文
posted @ 2015-02-18 10:24 lichen782 阅读(374) 评论(0) 推荐(0) 编辑
  2015年2月16日
摘要: Distinct SubsequencesGiven a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is... 阅读全文
posted @ 2015-02-16 20:40 lichen782 阅读(467) 评论(0) 推荐(0) 编辑
  2015年2月1日
摘要: 题目是这样的:The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following seque... 阅读全文
posted @ 2015-02-01 10:38 lichen782 阅读(555) 评论(0) 推荐(0) 编辑
  2013年7月25日
摘要: 今天在切leetcode的时候看到一个Morris算法,用来中序遍历二叉树,非递归,O(1)空间。觉得很强大。记录一下。基本思想是利用了Threaded Binary Tree。步骤如下:current节点设置为root。如果current不为空,到2,否则返回;如果current没有左子树,输出current的值,current等于current.right;如果current有左子树,首先找到current节点的precedent,也就是该节点左子树中最最右边那个节点。然后把最最右边这个节点的右link指向当前节点。如下图。 e.g. 当current是7的时候,我们找到4,并人为地... 阅读全文
posted @ 2013-07-25 15:14 lichen782 阅读(836) 评论(0) 推荐(0) 编辑
  2013年7月24日
摘要: 题目:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="aadbbbaccc", return false.这个题目值得记录的原因除了自己的解法没有通过大集合以外,主要还在与对动态规划的理解。在这两个月研究算法的过程中,我发现自己更倾向于直观的理解,而抽象思维上相对较弱 阅读全文
posted @ 2013-07-24 12:06 lichen782 阅读(5255) 评论(1) 推荐(1) 编辑
  2013年7月21日
摘要: 题目:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation ofs1="great": great / \ gr eat / \ / \g r e at / \ a tTo scramble the string, we may choose any non-leaf... 阅读全文
posted @ 2013-07-21 17:18 lichen782 阅读(1960) 评论(1) 推荐(0) 编辑