上一页 1 2 3 4 5 6 7 8 ··· 19 下一页
摘要: 题目 代码 线性dp 1 class Solution { 2 public: 3 int findLengthOfLCIS(vector<int>& nums) { 4 if(nums.size() <= 1) return nums.size(); 5 vector<int>dp(nums.si 阅读全文
posted @ 2021-03-10 17:05 Uitachi 阅读(58) 评论(0) 推荐(0)
摘要: 题目 代码 1 class Solution { 2 public: 3 int lengthOfLIS(vector<int>& nums) { 4 if(nums.size() <= 1) return nums.size(); 5 vector<int>dp(nums.size()+1,1); 阅读全文
posted @ 2021-03-10 16:51 Uitachi 阅读(49) 评论(0) 推荐(0)
摘要: 题目 代码 1 class Solution { 2 public: 3 int dfs(TreeNode* root){ 4 if(root == NULL) return 0; 5 int left = dfs(root->left); //左 6 int right = dfs(root->r 阅读全文
posted @ 2021-03-09 18:16 Uitachi 阅读(38) 评论(0) 推荐(0)
摘要: 题目 分析 开一个栈来记录左括号位置,而不是记录左括号。扫描原字符串,遇到右括号,查看栈是否空,若不空则匹配,若空则不匹配。扫描结束后,查看栈是否为空,若不空,则栈中存放的是未匹配的的左括号。 代码 1 #include<iostream> 2 #include<string> 3 #include 阅读全文
posted @ 2021-03-07 21:59 Uitachi 阅读(147) 评论(0) 推荐(0)
摘要: 题目 通过本题学习KMP 代码 1 #include<iostream> 2 using namespace std; 3 4 const int MAXM = 10000; 5 const int MAXN = 1000000; 6 7 int nextTable[MAXM]; 8 int pat 阅读全文
posted @ 2021-03-07 16:26 Uitachi 阅读(66) 评论(0) 推荐(0)
摘要: 题目 2003年清华大学计算机考研上机 本题不可直接O(n)来搜索,数据量大,千万级别,1s过不去,所以采用二分查找。 代码 1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 阅读全文
posted @ 2021-03-02 21:59 Uitachi 阅读(130) 评论(0) 推荐(0)
摘要: 题目 代码 网上别人 1 #include<iostream> 2 #include<vector> 3 4 using namespace std; 5 6 int main(){ 7 int n, m; 8 while(cin >> n >> m){ 9 // students[i] 表示第 i 阅读全文
posted @ 2021-03-02 20:34 Uitachi 阅读(122) 评论(0) 推荐(0)
摘要: 题目 本题不能用快排,会超时,因为数据量大。若用快排将会是千万的复杂度,1s内过不去。本题采用哈希,将NlogN算法降低为N 代码 1 #include<iostream> 2 using namespace std; 3 #define OFFSET 500000 4 int h[1000001] 阅读全文
posted @ 2021-03-02 20:09 Uitachi 阅读(93) 评论(0) 推荐(0)
摘要: 题目 2006年浙大机试题 代码 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 5 int main(){ 6 int n; 7 while(scanf("%d",&n) != EOF){ 8 int a[10 阅读全文
posted @ 2021-03-02 18:06 Uitachi 阅读(55) 评论(0) 推荐(0)
摘要: 题目 代码 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 5 int ISYEAP(int x){ 6 if((x%100!=0 && x % 4 == 0) || (x % 400 == 0) )return 阅读全文
posted @ 2021-03-02 17:49 Uitachi 阅读(93) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 ··· 19 下一页