问题: 给定数组,求所有子数组的最大值最小值之差的总和是多少。 这个数若太大了,对其进行取kMod=10^9+7的模 Example 1: Input: [2,1,3] Output: 6 Explanation: Subsequences are [1], [2], [3], [2,1], [2, ...
分类:
其他好文 时间:
2020-05-16 16:23:50
阅读次数:
52
此博客链接:https://www.cnblogs.com/ping2yingshi/p/12890315.html 删除回文子序列(58min) 题目链接:https://leetcode-cn.com/problems/remove-palindromic-subsequences/ 给你一个字 ...
分类:
其他好文 时间:
2020-05-14 19:12:54
阅读次数:
53
你有一个长度为 $ n \le 100 $ 的字符串。对于一个长度为 $ m $ 的子序列,选出它的花费是 $ n-m $,也就是你需要删掉的字符数量。你的任务是选出 $ k $ 个**本质不同**的子序列,使得总花费最小。输出这个最小花费。如果选不出 $ k $ 个,输出 $ -1 $。 ...
分类:
其他好文 时间:
2020-05-09 14:18:27
阅读次数:
67
题意:给你一个数组a,询问m次,每次返回长度为k的和最大的子序列(要求字典序最小)的pos位置上的数字. 题解:和最大的子序列很简单,排个序就行,但是题目要求字典序最小,那我们在刚开始的时候先记录每个数的位置再排序,然后选出k个最大的数后在对位置从小到大排个序就行了(这题有个坑,第一次排序的时候记得 ...
分类:
其他好文 时间:
2020-04-26 12:31:14
阅读次数:
66
E Erase Subsequences "Link" Solution $t$最多由两个串构成,设分别为$t1$,$t2$(可为空串). 要检查是否合法,首先枚举$t1$,$t2$的分界线,然后一个$n^3$$dp$显然: 设$f_{i,j,k}$表示当前到了$s_i$,同时已经匹配到$t1_j$ ...
分类:
其他好文 时间:
2020-04-21 00:00:10
阅读次数:
63
Given a string str and a dictionary dict, you need to find out which words in the dictionary are subsequences of the string and return those words.The ...
分类:
其他好文 时间:
2020-03-18 10:05:00
阅读次数:
74
Given a string S, count the number of distinct, non-empty subsequences of S . Since the result may be large, return the answer modulo 10^9 + 7. Exampl ...
分类:
其他好文 时间:
2020-03-18 09:38:23
阅读次数:
52
[toc] ? 1332. 删除回文子序列 https://leetcode cn.com/problems/remove palindromic subsequences/ 描述 ? 884. 两句话中的不常见单词 https://leetcode cn.com/problems/uncommon ...
分类:
其他好文 时间:
2020-03-15 13:31:04
阅读次数:
53
"E Erase Subsequences" 参考: "Educational Codeforces Round 82 A~E 题解" 该题数据范围只有400,所以可以使用$O(n^3)$的写法。 $dp[i][j]$表示在 s 的第 i 个位置(从1开始)和 t1 的第 j 个位置,能够满足的 t ...
分类:
其他好文 时间:
2020-02-13 18:54:51
阅读次数:
57
转换一下题意,就相当于问t能不能和s中2个不相同的子串相同,我们可以将t串拆成2个子串t1,t2,得到状态dp[i][j][k]=0/1,表示s判断到i位,t1判断到j位,t2判断到k位,0/1表示是否满足 两个状态,s[i]与t1[j]相匹配,s[i]与t2[k]相匹配 dp[i+1][j+1][ ...
分类:
其他好文 时间:
2020-02-13 17:24:56
阅读次数:
85