Sequence

最长斐波那契序列-LeetCode-873

不羁的心 提交于 2020-05-04 04:28:04
英文版 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 integers forming a sequence, find the length of the longest fibonacci-like subsequence of A. If one does not exist, return 0. (Recall that a subsequence is derived from another sequence A by deleting any number of elements (including none) from A, without changing the order of the remaining elements. For example, [3, 5, 8] is a subsequence of [3, 4, 5, 6, 7, 8].) Example 1: Input: [1,2,3,4,5,6,7,8] Output: 5 Explanation: The longest

1135 Is It A Red-Black Tree (30 分)

梦想与她 提交于 2020-05-04 03:31:20
1135 Is It A Red-Black Tree (30 分) There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties: (1) Every node is either red or black. (2) The root is black. (3) Every leaf (NULL) is black. (4) If a node is red, then both its children are black. (5) For each node, all simple paths from the node to descendant leaves contain the same number of black nodes. For example, the tree in Figure 1 is a red-black tree, while the ones in Figure 2 and 3 are not. Figure 1 Figure 2 Figure 3 For each given binary search tree, you are supposed to

[PAT] 1007 Maximum Subsequence Sum (25 分)Java

牧云@^-^@ 提交于 2020-05-04 03:29:06
1007 Maximum Subsequence Sum (25 分) 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 ≤ i ≤ j ≤ K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For example, given sequence { -2, 11, -4, 13, -5, -2 }, its maximum subsequence is { 11, -4, 13 } with the largest sum being 20. Now you are supposed to find the largest sum, together with the first and the last numbers of the maximum subsequence. Input Specification: Each input file

[LeetCode] 891. Sum of Subsequence Widths 子序列宽度之和

[亡魂溺海] 提交于 2020-05-04 03:24:02
<br> Given an array of integers `A`, consider all non-empty subsequences of `A`. For any sequence S, let the width of S be the difference between the maximum and minimum element of S. Return the sum of the widths of all subsequences of A. As the answer may be very large, return the answer modulo 10^9 + 7. Example 1: Input: [2,1,3] Output: 6 Explanation: Subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3]. The corresponding widths are 0, 0, 0, 1, 1, 2, 2. The sum of these widths is 6. Note: 1 <= A.length <= 20000 1 <= A[i] <= 20000 <br> 这道题给了我们一个数组,并且定义了一种子序列的宽度,就是非空子序列中最大值和最小值的差值

Leetcode 446.等差数列划分II 子序列

喜你入骨 提交于 2020-05-04 03:23:46
等差数列划分II 子序列 如果一个数列至少有三个元素,并且任意两个相邻元素之差相同,则称该数列为等差数列。 例如,以下数列为等差数列: 1, 3, 5, 7, 9 7, 7, 7, 7 3, -1, -5, -9 以下数列不是等差数列。 1, 1, 2, 5, 7 数组 A 包含 N 个数,且索引从 0 开始。该数组 子序列 将划分为整数序列 (P 0 , P 1 , ..., P k ),P 与 Q 是整数且满足 0 ≤ P 0 < P 1 < ... < P k < N。 如果序列 A[P 0 ],A[P 1 ],...,A[P k-1 ],A[P k ] 是等差的,那么数组 A 的 子序列 (P0,P1,…,PK) 称为等差序列。值得注意的是,这意味着 k ≥ 2。 函数要返回数组 A 中所有等差子序列的个数。 输入包含 N 个整数。每个整数都在 -2 31 和 2 31 -1 之间,另外 0 ≤ N ≤ 1000。保证输出小于 2 31 -1。 示例: 输入: [2, 4, 6, 8, 10] 输出: 7 解释: 所有的等差子序列为: [2,4,6] [4,6,8] [6,8,10] [2,4,6,8] [4,6,8,10] [2,4,6,8,10] [2,6,10] Dynamic Programming [Accepted] Intuition To determine

[LeetCode] 659. Split Array into Consecutive Subsequences 将数组分割成连续子序列

做~自己de王妃 提交于 2020-05-04 02:58:37
You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into several subsequences, where each subsequences consist of at least 3 consecutive integers. Return whether you can make such a split. Example 1: Input: [1,2,3,3,4,5] Output: True Explanation: You can split them into two consecutive subsequences : 1, 2, 3 3, 4, 5 Example 2: Input: [1,2,3,3,4,4,5,5] Output: True Explanation: You can split them into two consecutive subsequences : 1, 2, 3, 4, 5 3, 4, 5 Example 3: Input: [1,2,3,4,4,5] Output: False Note: The length of the input is in range

退役前的记录(2018.10.14-NOIP2018)

我的梦境 提交于 2020-05-04 02:50:26
退役前的记录 诸位好,我是$CJ$最菜的$Oier$,已经是$G2$的老年选手了,不知道什么时候就会退役了,总之$G1\ double$的机会已经没有了,去年因为联赛失利而止步,而今年虽然有了很大的进步,但留给我犯错的机会却没有了,联赛,$WC$,省选,$SC$,$NOI$,我不知道我能坚持到什么时候,只要有一点失误,就真的要退役了。在这新的赛季,我不知道我什么时候就会永远的离开$OI$,只是想记下这$OI$生涯最后的时光,在退役之后也能留下奋斗过的痕迹,能让我在往后回忆起这段时光时不悔当初。 ##10.14 上午休息。下午写了几个远古的省选题,感觉以前的题目是真的良心。然后看了下今年湖南省选的题,突然发现我考场上是有多SB才没写出$D2T3$这种普及难度的树$DP$,顺手切了之后看看到$D2T1$,突然会做了,然后得出一个结论$:$我是一个傻逼。 晚上趣题分享,感觉全是毒瘤题,什么切树游戏(详情请见猫琨博客中的 基于变换合并的树上动态 DP 的链分治算法 & SDOI2017切树游戏(cut)解题报告 )。 然后把下午想出的题写了。 ##10.15 上午考试,出题人$Cyhlnj$,感觉题目还行吧,就是代码量比较大,然而神仙$ZSY,GZY$差点阿克。果然还是我太菜了,40+100+0, $T1:$排列计数,复杂度正确,大样例过了,感觉这种题这样就妥妥的,然而直接被打脸,只有40

当地使用impdp导出服务器转储文件,本地使用impdp导入远程数据库用户

谁说我不能喝 提交于 2020-05-04 02:43:22
本地使用impdp导出服务器转储文件,本地使用impdp导入远程数据库用户 1)expdp是可以在客户端上生成转储文件的 2)impdp是可以在不同的实例之间进行数据的迁移复制的 练习1: 1)将远程数据库WSJB用户使用expdp命令导出到本地磁盘的D:\下 Microsoft Windows [版本 6.1.7600] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\windows\system32> sqlplus system/system SQL*Plus: Release 11.1.0.6.0 - Production on 星期四 1月 10 13:49:34 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. 连接到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> input 1 create public database link wsjb 2 connect to wsjb

2018 Multi-University Training Contest

狂风中的少年 提交于 2020-05-04 00:25:54
Solved A HDU 6298 Maximum Multiple Solved B HDU 6299 Balanced Sequence Solved C HDU 6300 Triangle Partition Solved D HDU 6301 Distinct Values E HDU 6302 Maximum Weighted Matching F HDU 6303 Period Sequence Solved G HDU 6304 Chiaki Sequence Revisited Solved H HDU 6305 RMQ Similar Sequence I HDU 6306 Lyndon Substring J HDU 6307 Turn Off The Light Solved K HDU 6308 Time Zone A 找规律 发现只有3和4的倍数有存在答案 #include <bits/stdc++.h> #define ll long long #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define rep(ii,a,b) for(int ii=a;ii<=b;ii++) #pragma comment(linker, "/stack:200000000")

LeetCode第[44]题(Java):Wildcard Matching

耗尽温柔 提交于 2020-05-03 22:43:51
题目 :通配符匹配 难度 :hard 题目内容 : Given an input string ( s ) and a pattern ( p ), implement wildcard pattern matching with support for '?' and '*' . '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). Note: s could be empty and contains only lowercase letters a-z . p could be empty and contains only lowercase letters a-z , and characters like ? or * . 翻译 :给定一个输入字符串(s)和一个模版(p),实现通配符模式匹配,并支持“?””和“*”。 ”?匹配任何一个字符。 “匹配任何字符序列(包括空序列)。 匹配应该覆盖整个输入字符串(而不是部分)。 注意: s可以是空的,并且只包含小写字母a-z。 p可以是空的