Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest i ...
分类:
其他好文 时间:
2018-02-01 11:41:59
阅读次数:
170
3. Longest Substring Without Repeating Characters (medium) 最长的无重复的子字符串 Given a string, find the length of the longest substring without repeating char ...
分类:
其他好文 时间:
2018-02-01 10:45:51
阅读次数:
180
32. Longest Valid Parentheses 题目 解析 对于括号匹配,和Valid Parentheses同样的思路,用栈维护左括号,即在读取字符串的时候,遇到左括号就入栈。遇到右括号就出栈,同时判断当前括号匹配的子串是否为最长子串。不过在判断括号匹配的子串的长度的时候,有一些值得注 ...
分类:
其他好文 时间:
2018-01-30 16:31:34
阅读次数:
166
题目: Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. ...
分类:
其他好文 时间:
2018-01-29 17:35:00
阅读次数:
145
Description Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Sample 思路 回文串是正着读、反着读都 ...
分类:
其他好文 时间:
2018-01-29 16:22:31
阅读次数:
186
一、最长公共子串(Longest Common Substring) 遍历的时候用一个二维数组存储相应位置的信息,如果两个子串1与子串2相应位置相等:则看各自前一个位置是否相等,相等则该位置值B[i][j]=B[i-1][j-1]+1,不相等则置为1。如果两个子串1与子串2相应位置不相等,则B[i] ...
分类:
其他好文 时间:
2018-01-25 19:50:22
阅读次数:
128
题意 给定$n$个数,求最长上升子序列的方案数 根据数据范围要求是$O(n\log n)$ 朴素的dp方程式$f_i=max(f_j+1),a_i a_j$,所以记方案数为$v_i$,则$v_i=v_i+v_j,(f_i=f_j+1)$,利用lis的$O(n\log n)$树状数组做法同时维护长度和 ...
分类:
编程语言 时间:
2018-01-25 00:12:05
阅读次数:
163
b.compareTo(a) 这个函数是比较两个值得大小,如果b比a大,那么返回1 如果小,那么返回-1,相等返回0 如果比较的是字符串,那么比较字典编纂顺序,b靠前返回-1,靠后返回1 这个题的核心虽然是hashtable,但是这个方法还是很重要的,因为自己实现比较字符串很麻烦 ...
分类:
其他好文 时间:
2018-01-24 22:17:53
阅读次数:
756
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the ...
分类:
其他好文 时间:
2018-01-21 13:41:28
阅读次数:
113
Longest Palindromic Substring 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/longest palindromic substring/description/ Description Given a string s, ...
分类:
其他好文 时间:
2018-01-20 20:30:23
阅读次数:
151