Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the lon ...
分类:
其他好文 时间:
2019-04-05 20:07:23
阅读次数:
186
```java public int lengthOfLongestSubstring(String s) { int i = 0, j = 0, max = 0; Set set = new HashSet(); while(j ...
分类:
编程语言 时间:
2019-04-05 14:03:33
阅读次数:
134
本题大意:和LIS一样 本题思路:用dp[ i ]保存前 i 个数中的最长递增序列的长度,则可以得出状态转移方程dp[ i ] = max(dp[ j ] + 1)(j < i) 参考代码: 1 #include <iostream> 2 #include <cstring> 3 #include ...
分类:
其他好文 时间:
2019-04-03 14:06:06
阅读次数:
152
题目要求 Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is ...
分类:
其他好文 时间:
2019-04-01 11:50:44
阅读次数:
137
description: Write a function to find the longest common prefix string amongst an array of strings. 找到几个字符串的最大前缀,英语不好是硬伤gg prefix string 前缀!!!!! If th ...
分类:
其他好文 时间:
2019-03-30 10:19:50
阅读次数:
152
网址:https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/ 其实就是斐波那契数列,没什么好说的。 注意使用3个变量,而不是数组,可以节约空间。 ...
分类:
其他好文 时间:
2019-03-28 00:32:21
阅读次数:
163
Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer ...
分类:
其他好文 时间:
2019-03-27 12:29:56
阅读次数:
157
A sequence X_1, X_2, ..., X_n is fibonacci-like if: n >= 3 X_i + X_{i+1} = X_{i+2} for all i + 2 <= n Given a strictly increasing array A of positive ...
分类:
其他好文 时间:
2019-03-23 12:58:30
阅读次数:
118
编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 知识点1: 方法:String.indexOf(String) while (strs[i]. indexOf(prefix) != 0) {...} 这个循环用来比较两个字符串,直到找到完全相同的前缀(因为p ...
分类:
其他好文 时间:
2019-03-20 15:48:31
阅读次数:
188
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe ...
分类:
其他好文 时间:
2019-03-20 11:44:09
阅读次数:
150