LIS of Sequence 我们先找出那些肯定不会再LIS里面。 然后我们从前往后扫一次, 当前位置为 i , 看存不存在一个 j 会在lis上并且a[ j ] > a[ i ], 如果满足则 i 能被省掉。 在从后往前扫一遍就做完啦。 ...
分类:
其他好文 时间:
2019-02-17 23:33:20
阅读次数:
160
"124. Longest Consecutive Sequence" / "128. Longest Consecutive Sequence" 本题难度: Medium/Hard Topic: Data Structure Description Given an unsorted array ...
分类:
其他好文 时间:
2019-02-17 15:31:49
阅读次数:
223
题目要求 Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. Two binary trees are c ...
分类:
其他好文 时间:
2019-02-17 11:15:34
阅读次数:
185
A. Integer Sequence Dividing 1 #include <cstdio> 2 3 using namespace std; 4 int n; 5 6 int main(){ 7 scanf("%d",&n); 8 if((n+1)%2==0){ 9 n=(n+1)/2; 10 ...
分类:
其他好文 时间:
2019-02-16 13:48:53
阅读次数:
134
长度为n的环状串有n种表示法,分别为从某 个位置开始顺时针得到。例如,图3-4的环状串 有10种表示: CGAGTCAGCT,GAGTCAGCTC,AGTCAGCTCG等。 在这些表示法中,字典序最小的称 为"最小表示"。 输入一个长度为n(n≤100)的环状DNA串(只包含A、C、G、T这4种字符 ...
分类:
其他好文 时间:
2019-02-15 22:32:46
阅读次数:
185
Difficulty: Medium Problem Given an array , we can perform a pancake flip : We choose some positive integer `k PancakeSort(int[] A) { int max = A.Leng ...
分类:
其他好文 时间:
2019-02-14 23:57:08
阅读次数:
329
考虑按顺序暴搜子序列。如果序列中的数两两不同,显然每次给上一个找到的子序列添上后缀最小值,即为下一个要找的子序列。如果不能再加了就回溯继续考虑后缀次小、第三小……值,直到找到k个子序列。 有重复的数后,考虑后缀k小值只取第一次出现的位置,并在每找到一个子序列后就统计其出现次数。显然这样就能找到所有要 ...
分类:
其他好文 时间:
2019-02-14 20:36:30
阅读次数:
168
The well known Fibonacci sequence is obtained by starting with 0 and 1 and then adding the two last numbers to get the next one. For example the third ...
分类:
其他好文 时间:
2019-02-14 00:20:19
阅读次数:
131
Given is a set of integers and then a sequence of queries. A query gives you a number and asks to find a sum of two distinct numbers from the set, whi ...
分类:
其他好文 时间:
2019-02-13 22:54:34
阅读次数:
199
Given a sequence of K integers { N?1??, N?2??, ..., N?K?? }. A continuous subsequence is defined to be { N?i??, N?i+1??, ..., N?j?? } where 1. The Max ...
分类:
其他好文 时间:
2019-02-13 18:19:59
阅读次数:
163