![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
Douglas_LT
这个作者很懒,什么都没留下…
展开
-
最长递增子序列
每日一题ing,今天是个medium题300. Longest Increasing Subsequenceclass Solution {public: vector<vector<int>> permute(vector<int>& nums) { int len=nums.size(); vector<vector<int>> ret; dfs(nums,ret,0,len)原创 2022-03-20 15:15:16 · 125 阅读 · 0 评论 -
非递减数列
每日一题ing,今天是个medium题665. Non-decreasing Arrayclass Solution {public: bool checkPossibility(vector<int>& nums) { int len=nums.size(),count=0; if(len<=1){ return true; } for(int i=1;i<len;i++)原创 2022-01-23 14:46:27 · 248 阅读 · 0 评论 -
贪心之区间问题(1)
每日一题ing,今天是个medium题力扣435. Non-overlapping Intervalsclass Solution {public: int candy(vector<int>& ratings) { int min=0; vector<int> mark; for(int i=0;i<ratings.size();i++) { mark.push_bac原创 2022-01-16 21:36:52 · 265 阅读 · 0 评论 -
codeup最长回文子串
codeup最长回文子串#pragma warning(disable :4996)#include<iostream>#include<cstdlib>#include<cstdio>#include <stdio.h>#include<string> #include<vector>#include<algorithm>#include<map>using namespace std;原创 2020-11-22 19:20:00 · 152 阅读 · 0 评论 -
最长公共子序列
#pragma warning(disable :4996)#include<iostream>#include<cstdlib>#include<cstdio>#include <stdio.h>#include<string> #include<vector>#include<algorithm>#include<map>using namespace std;int main(){原创 2020-11-21 15:44:29 · 94 阅读 · 0 评论 -
输入两个字符串,输出最长相同子串
#pragma warning(disable :4996)#include<iostream>#include<cstdlib>#include<cstdio>#include <stdio.h>#include<string> #include<vector>#include<algorithm>#include<map>using namespace std;typedef long原创 2020-11-20 19:18:52 · 932 阅读 · 0 评论 -
计算器 中缀表达式
#include<iostream>#include<string>#include<queue>#include<stack>#include<map>#include<cstdio>using namespace std;struct node{ bool opORnum; double num; char opre;};string str;queue<node>q;stack<原创 2020-11-13 13:39:13 · 425 阅读 · 0 评论 -
1068 Find More Coins (30分) 01背包问题变形(扣7分)
错误点:1.两处内存超限2.一处答案错误#pragma warning(disable:4996)#include<stdio.h>#include<string>#include<algorithm>#include<iostream>using namespace std;struct info{ int weight; int value;}package[10010];int dp[10010][10010];int f原创 2020-07-24 17:30:09 · 129 阅读 · 0 评论 -
PAT1040 Longest Symmetric String (25分) 最长回文子串
#pragma warning(disable:4996)#include<stdio.h>#include<string>#include<algorithm>using namespace std;int dp[1010][1010];int strlen(char s[]){ int i = 0; while (s[i] != '\0') i++; return i;}int main(){ char s[1010]; int原创 2020-07-22 15:23:49 · 119 阅读 · 0 评论 -
PAT甲级1045 Favorite Color Stripe (30分) 动态规划
稍稍变形的最长公共子序列#pragma warning(disable:4996)#include<stdio.h>#include<string>#include<algorithm>using namespace std;int dp[10010][10010];int main(){ int a[10010], b[10010]; int n, m, l; scanf("%d", &n); scanf("%d", &m);原创 2020-07-22 10:37:54 · 127 阅读 · 0 评论 -
PAT甲级1007 Maximum Subsequence Sum (25分) 动态规划
#pragma warning(disable:4996)#include<iostream>#include<string>#include<cstdio>#include<cmath>#include<algorithm>using namespace std;int main(){ int n,a[10010],dp[10010],s[10010]; scanf("%d", &n); int flag = 1;原创 2020-07-19 22:01:05 · 173 阅读 · 0 评论 -
PAT乙级1020 月饼 (25分) 贪心方法
注意库存小于需求量的情况#pragma warning(disable:4996)#include<iostream>#include<string>#include<cstdio>#include<cmath>#include<algorithm>using namespace std;struct info{ double weight; double price;}infor[1010];int main()原创 2020-07-18 21:29:21 · 155 阅读 · 0 评论 -
回溯法解决5皇后问题
#pragma warning(disable:4996)#include<iostream>#include<string>#include<cstdio>#include<cmath>using namespace std;int n = 5;int flag[6], pre[6];void init(){ memset(flag, 0, sizeof(flag)); memset(pre, 0, sizeof(pre));}原创 2020-07-17 16:46:11 · 2547 阅读 · 0 评论