daydayup牛
daydayup牛
全部文章
分类
题解(97)
归档
标签
去牛客网
登录
/
注册
daydayup牛的博客
全部文章
(共96篇)
题解 | #输入n个整数,输出其中最小的k个#
排序算法第四篇,归并排序 #include <algorithm> #include <vector> using namespace std; void merge(vector<int> &L,int left,int mid,int right)...
C++
排序树
2022-03-26
0
353
题解 | #输入n个整数,输出其中最小的k个#
排序算法第三篇 算法库自带的堆排序 #include <algorithm> #include <vector> using namespace std; vector<int> & mysort(vector<int> & ...
C++
排序树
2022-03-26
0
365
题解 | #输入n个整数,输出其中最小的k个#
排序算法第3篇,简单选择排序和堆排序 #include <algorithm> #include <vector> using namespace std; void maxsift(vector<int> &v,int start,int end){...
C++
排序树
2022-03-26
0
342
题解 | #输入n个整数,输出其中最小的k个#
算法总结第二篇,希尔排序和起泡和快速排序(递归) #include <algorithm> #include <vector> using namespace std; int mypartion(int low,int high,vector<int> &a...
C++
排序树
2022-03-26
0
387
题解 | #输入n个整数,输出其中最小的k个#
排序算法总结1 #include <algorithm> #include <vector> using namespace std; vector<int> & mysort(vector<int> & v){ /*int...
C++
排序树
2022-03-26
0
337
题解 | #查找两个字符串a,b中的最长公共子串#
压缩一下,空间复杂度一下就降下来了,不停的更新每一行就行了,把短的字符串弄到第一行。 其实可以看出有公共子串其实就是矩阵里不为0的位置连在一起。 ```#include <iostream> #include <algorithm> #include <vector&...
C++
动态规划
字符串
2022-03-25
0
364
题解 | #查找两个字符串a,b中的最长公共子串#
动态规划,以第i和j个字符结尾的公共子串若存在则长度为dp[i][j],若str1[i]==str2[j]则dp[i][j]=dp[i-1][j-1]+1。求出最长并输出就行了,这个动态规划还可以压缩 #include <algorithm> #include <vector>...
C++
动态规划
2022-03-25
0
308
题解 | #查找两个字符串a,b中的最长公共子串#
暴力解,时间复杂度O(N^3),空间复杂度O(1) #include <algorithm> using namespace std; int main() { string str1,str2; while(cin>>str1>>str2){...
C++
字符串
2022-03-25
0
291
题解 | #走方格的方案数#
排列组合,我们知道它随便怎么走都是m+n步那我们m+n里挑m步进行选择就是C(m)/(m+n),不知道怎么输出排列组合,,ԾㅂԾ,, #include <algorithm> using namespace std; int permutation(const int n,const...
C++
数学
2022-03-25
0
294
题解 | #走方格的方案数#
递归思路很优雅,当然你用排列组合更优雅 #include <algorithm> using namespace std; int dfs(int x,int y,const int&n,const int&m){ if(x>n||y>m) ret...
C++
递归
2022-03-25
0
247
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页