Suppose there is a h×wh×w grid consisting of empty or full cells. Let's make some definitions: riri is the number of consecutive full cells connected ...
分类:
其他好文 时间:
2019-09-30 18:12:34
阅读次数:
122
Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, ...
分类:
其他好文 时间:
2019-09-29 09:14:16
阅读次数:
113
Difficulty: Hard More:【目录】LeetCode Java实现 Description Given a string containing just the characters '(' and ')', find the length of the longest valid ...
分类:
其他好文 时间:
2019-09-28 23:13:49
阅读次数:
116
Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Note: There may be more than one LIS combination, it ...
分类:
其他好文 时间:
2019-09-28 11:16:10
阅读次数:
106
题目: 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 题解: i j 分别记录目标字符串的左右边界。对当前字符 x,如果前面出现过,则更新左边界为上次出现位置的下一个,然后更新当前字符 x 的位置,遍历过程中记录一下 j - i + 1的最大值就好了。 ...
分类:
其他好文 时间:
2019-09-19 09:15:42
阅读次数:
50
编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 输入: ["flower","flow","flight"]输出: "fl"示例 2: 输入: ["dog","racecar","car"]输出: ""解释: 输入不存在公共前缀。说明: 所有输入 ...
分类:
编程语言 时间:
2019-09-14 15:51:50
阅读次数:
140
[Leetcode] 32.最长有效括号 关键词:DP,动态规划,动规。 最近在刷DP专栏的题目,这是其中一道题。 给定一个只包含 和 的字符串,找出最长的包含有效括号的子串的长度。 "longest valid parentheses" Sample1 Sample2 对于DP嘛,首先还是需要抽象 ...
分类:
其他好文 时间:
2019-09-13 15:33:51
阅读次数:
97
[徐州网络赛]Longest subsequence 可以分成两个部分,前面相同,然后下一个字符比对应位置上的大。 枚举这个位置 用序列自动机进行s字符串的下标转移 注意最后一个字符 c++ include const int maxn = 1e6 + 7; using namespace std; ...
分类:
其他好文 时间:
2019-09-13 13:48:22
阅读次数:
89
"Longest Subarray" 题意:一个数列,每个元素大小都在1到C之间,求一个最长的子串,满足在这个子串中1到C之间的每个数字要么出现0次,要么出现至少K次。 题解:$i$从1到n枚举右端点,维护一个$tree[j]$表示在$i$为右端点时以$j$为左端点可行的个数(这里的可行是指对于1到 ...
分类:
其他好文 时间:
2019-09-11 00:01:04
阅读次数:
105
原题链接在这里:https://leetcode.com/problems/longest-turbulent-subarray/ 题目: A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if: ...
分类:
其他好文 时间:
2019-09-08 09:45:15
阅读次数:
68