
数据结构和算法
文章平均质量分 50
Yilia_wy
这个作者很懒,什么都没留下…
展开
-
最大子序列和算法
题目:求A[i]中和最大的子序列。时间复杂度O(NlogN): 使用分治+递归的方法。分别求出左边N/2长度的最大子序列和、右边N/2长度的最打字序列和、以及横跨这两部分且通过中间的最大和(要分别求出两边带有最中间边界的最子大序列和,将其相加),由于不是最简单的方法,这里不再赘述。时间复杂度O(N):遍历一遍A即可得到结果:原创 2015-09-14 14:49:34 · 491 阅读 · 0 评论 -
Leetcode-198-House Robber
题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacen原创 2017-02-21 16:16:38 · 233 阅读 · 0 评论 -
Leetcode-516-Longest Palindromic Subsequence
Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.题目的意思是找到字符串s中最长的回文子序列:Example 1:Input:"bbbab"Output:4原创 2017-02-22 15:22:18 · 274 阅读 · 0 评论