摘要: 思路: 经典dp (1)找状态,从后到前,目标:result[i][j]表示,A[i]与B[j]的最长公共子序列(i<=n,j<=m)。 (2)确定状态转移方程,二种决策(a[i] b[i]一样, a[i] b[i]不一样) (3)复杂度为O(lenA*lenB),此种解法为递推,从前到后,使用循环 阅读全文
posted @ 2016-10-09 21:28 choles 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 思路: 默认数组第一个是prefix,然后循环比较数组中的每一个字符串,直到不相等,返回substring即可,返回的substring一定是最长的公共前缀。 注:判断数组为空或者数组中有空字符串 时间复杂度:O(第一个字符串长度^2),java耗时1563 ms。 阅读全文
posted @ 2016-10-09 15:53 choles 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 作者:Hawstein出处:http://hawstein.com/posts/dp-novice-to-advanced.html声明:本文采用以下协议进行授权:自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0,转载请注明作者及出处。前言本文翻译自To... 阅读全文
posted @ 2015-03-04 16:49 choles 阅读(191) 评论(0) 推荐(0) 编辑
摘要: DP类题目找到子问题(状态),然后找到转移方程,就OK#dp#likes matrixchain#according to two point's distance to recurrenceclass Solution: # @return a string def longest... 阅读全文
posted @ 2015-03-04 16:42 choles 阅读(192) 评论(0) 推荐(0) 编辑
摘要: #title#Longest Substring Without Repeating Characters #description:#Given a string, #find the length of the longest substring without #repeating chara... 阅读全文
posted @ 2015-02-03 12:01 choles 阅读(142) 评论(0) 推荐(0) 编辑
摘要: title: #Youaregiventwolinkedlistsrepresentingtwo #non-negativenumbers. #Thedigitsarestored. #inreverseorderandeachoftheirnodescontain #asingl... 阅读全文
posted @ 2015-02-03 09:36 choles 阅读(170) 评论(0) 推荐(0) 编辑
摘要: #title : Two Sum#Given an array of integers, find two numbers such#that they add up to a specific target number.#The function two Sum should return in... 阅读全文
posted @ 2015-02-02 13:18 choles 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 今天学习了Linux文件系统,现在来做个小总结。 首先Linux中一切都是文件,下面这个清单是Linux系统的顶层目录结构。 清单 1. Linux 系统的顶层目录结构 / 根目录 ├── bin 存放用户二进制文件 ├── boot 存放... 阅读全文
posted @ 2015-01-23 15:27 choles 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 下面是一段类似日志记录的代码,已获取通讯的报文内容和当时的环境参数内容,就是创建一个文件,使用标准IO的fopen、fprintf进行输出记录。但是在调试中,刚开始我就傻眼了,文件创建成功了,但是实时查看竟然没有任何数据记录。经过半天的担惊受怕和反复排查,发现是被标准IO的缓冲机制摆了一道,惭愧... 阅读全文
posted @ 2015-01-22 10:46 choles 阅读(1715) 评论(0) 推荐(0) 编辑
摘要: 上午在网上看到了斯考特·杨(Scott Young)的快速学习方法,感觉很受鼓舞。 现在已经读研究生了,可是发现自己自从上大学以来到现在,发现自己的学习方法有很大的问题。 我是个特别喜欢读书的人,在大学四年中,读了很多很多书籍,可是到现在,似乎都全部忘记了,书中的知识一点都没有记住,真感觉花... 阅读全文
posted @ 2015-01-21 11:40 choles 阅读(7428) 评论(0) 推荐(1) 编辑