2014年3月15日

LeetCode: Longest Palindromic Substring

摘要: Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest palindromic substring.来来回回用了好长时间。主要是O(n^2)的两种算法。最后还有一种O(n)的算法,但估计面试的时候是想不出来的,所以就只给个链接。第一种是用动态规划。O(n^2)时间,O(n^2)空间。table[i][j]标记string从i到j是不是palindrome。t 阅读全文

posted @ 2014-03-15 11:52 longhorn 阅读(166) 评论(0) 推荐(0) 编辑

导航