问题描述: 给定两个序列 X=, Y,求X和Y长度最长的公共子串。(子串中的字符要求连续) 这道题和最长公共子序列(Longest common subsequence)很像,也可以用动态规划定义。公式如下:这里c[i,j]表示以Xi,Yj结尾的最长公共子串的长度。程序实现:int longes.....
分类:
其他好文 时间:
2015-08-12 21:13:28
阅读次数:
142
问题定义: 给定一个长度为N的数组A,找出一个最长的单调递增子序列(不要求连续)。 这道题共3种解法。1. 动态规划 动态规划的核心是状态的定义和状态转移方程。定义lis(i),表示前i个数中以A[i]结尾的最长递增子序列的长度。可以得到以下的状态转移方程:d(i) = max(1, d(j)...
分类:
其他好文 时间:
2015-08-12 18:43:08
阅读次数:
109
题目:
数组中有一个数字出现的次数超过数组长度的一半,请找出这一个数字。输入一个长度为9的数组{1,2,3,2,2,2,5,4,2},
数字2在数组中出现的次数大于数组长度的一半,返回2。
这道题类似以前做过的Maximum Subarray。
按着以前的思路:
确定某一个数字,遇到相同的数字加1,遇到不同的数字减1,当累加器为0时,我们重新开始计算即可。
完成后继续判断这个数...
分类:
编程语言 时间:
2015-08-12 13:18:44
阅读次数:
160
设置:单个设置Shader.maximumLOD、全局设置Shader.globalMaximumLOD、QualitySettings里面的Maximum LODLevel 原理:小于指定值的shader和subshader才能被使用。 应用:有时候一些显卡虽然支持很多特性,但是效率很低,此时就可...
分类:
其他好文 时间:
2015-08-12 12:59:57
阅读次数:
133
题目Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window...
问题描述Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.解决思路1.定义Line类{slope; intercept; isVertical; isHor...
分类:
其他好文 时间:
2015-08-11 22:53:24
阅读次数:
163
August 10, 2015有二种解法, Greedy算法, 和DP算法. 二种算法都通过leetcode online judge. 贪婪算法, 花了一个小时理解代码, 修改后很好理解.Problem statement:Find the contiguous subarray within a...
分类:
其他好文 时间:
2015-08-11 09:44:20
阅读次数:
127
QestionGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, (the...
分类:
其他好文 时间:
2015-08-11 07:18:19
阅读次数:
124
描述: A numeric sequence ofaiis ordered ifa1#include#include#include#include using namespace std;#define N 1005int main(){ int n,temp,dp[N],seq[N],c...
分类:
其他好文 时间:
2015-08-11 00:08:26
阅读次数:
174
Common Subsequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28494 Accepted Submission(s): 12735
Problem Description
A sub...
分类:
其他好文 时间:
2015-08-10 14:57:48
阅读次数:
166