(1)问题描述:给定n个整数A1,A2,A3...An。按照从左往右的顺序选择尽可能多的整数,组成一个上升子序列,其中相邻元素不能相等。
(2)解题思路:本题就是经典的最长上升子序列问题(Longest Increasing Subsequence,LIS)。可以通过动态规划解决。定义状态d(i)表示以下标i结尾的LIS的最大长度。那么不难得到如下状态转移方程:
d(i)=max{0,d(j)...
分类:
其他好文 时间:
2015-05-16 09:14:04
阅读次数:
100
String str="我是中国人";str = str.substring(0, 2) +"_"+str.substring(3, 4);结果:str="我是_国"substring(int start,int end); //start:索引开始位置,当前字符计算在内 end:索引结束位置,当前...
分类:
编程语言 时间:
2015-05-15 17:10:31
阅读次数:
185
试题请參见:https://oj.leetcode.com/problems/longest-common-prefix/题目概述Write a function to find the longest common prefix string amongst an array of strings...
分类:
其他好文 时间:
2015-05-15 15:13:04
阅读次数:
104
Longest Ordered SubsequenceTime Limit:2000MSMemory Limit:65536KTotal Submissions:32192Accepted:14093DescriptionA numeric sequence ofaiis ordered ifa1i...
分类:
其他好文 时间:
2015-05-15 10:35:45
阅读次数:
128
functioncheck_date(){varbeginTime=$(‘#examStartTime‘).val();varendTime=$(‘#examEndTime‘).val();varbeginTimes=beginTime.substring(0,10).split(‘-‘);varendTimes=endTime.substring(0,10).split(‘-‘);beginTime=beginTimes[1]+‘-‘+beginTimes[2]+‘-‘+beginTimes[0]+‘‘+b..
分类:
Web程序 时间:
2015-05-15 01:29:12
阅读次数:
225
Write a function to find the longest common prefix string amongst an array of strings.
分类:
其他好文 时间:
2015-05-14 20:14:06
阅读次数:
99
Problem:
Given a string containing just the characters '(' and ')',
find the length of the longest valid (well-formed) parentheses substring.
For "(()", the longest valid parentheses substri...
分类:
编程语言 时间:
2015-05-14 18:44:41
阅读次数:
121
如表中有很多这样的数据: TEST-123,TEST-III 这种以 TEST开头的数据,为了统计其总数可以使用mysql自带的方法 substring_index()方法 第一个参数是列的内容, 第二个参数是包含的关键自负 第三个是包含几个这样的关键字符例子如下: SELECT substr...
分类:
数据库 时间:
2015-05-14 16:23:26
阅读次数:
162
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
分析;
此题是求二叉树的深度,(无所谓最大深度),用递归的方法很容...
分类:
其他好文 时间:
2015-05-14 14:18:49
阅读次数:
117
Problem:
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation
of each word in wordsexac...
分类:
编程语言 时间:
2015-05-14 14:17:31
阅读次数:
120