上一页 1 2 3 4 5 6 7 8 ··· 10 下一页
摘要: 问题描述 注意,如果数组里有两个元素的值相同,那么这两个元素是可以出现在同一个组合里的: 但是:如果按前面的思路分析的话,会发现结果中出现很多相同的组合。 像这样: 这很明显是由于两个相同的1造成的,因为当前的startindex对应第一个1时,向下一层递归后,starindex定位的还是1,。 如 阅读全文
posted @ 2024-03-07 21:39 SaTsuki26681534 阅读(4) 评论(1) 推荐(0) 编辑
摘要: 题目描述 #include<iostream> #include<vector> using namespace std; vector<vector<int> > res; vector<int> path; int accumulate(vector<int> path){ int sum; f 阅读全文
posted @ 2024-03-07 16:29 SaTsuki26681534 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 问题描述 class Solution { public: vector<string> res; string path; // char A[26] = {'a','b','c','d','e','f','g', // 'h','i','j','k','l','m','n','o','p','q 阅读全文
posted @ 2024-03-07 12:22 SaTsuki26681534 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 题目描述 2. 以下是回溯算法的模版 class Solution { private: vector<vector<int>> res; vector<int> path;//这个变量名还是设为path更合适 void backtrace(int n, int k, int startindex) 阅读全文
posted @ 2024-03-06 23:37 SaTsuki26681534 阅读(2) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/qq_30460949/article/details/89109807 阅读全文
posted @ 2024-03-06 15:48 SaTsuki26681534 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 题目描述 顾名思义 代码如下: #include<iostream> #include<string> #include<stack> using namespace std; bool isValid(string s){ if(s.empty()){ return true; } if(s.si 阅读全文
posted @ 2024-03-06 15:45 SaTsuki26681534 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 题目描述 通过这题可以了解如何在结构体中使用sort函数,以及sort函数第三个参数的意义。 整体代码如下: #include<iostream> #include<algorithm> using namespace std; struct stu { int num;//编号 int c,m,e 阅读全文
posted @ 2024-03-05 22:19 SaTsuki26681534 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 题目描述 代码: #include<iostream> #include<algorithm> using namespace std; int main(){ int n; cin>>n; int A[n]; for(int i = 0; i < n; i++){ cin>>A[i]; } sor 阅读全文
posted @ 2024-03-05 21:52 SaTsuki26681534 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 题目描述 如题所述,找到n个数中第K小的数字。 但是不同的是时间复杂度要求为O(n),也就是说基本上所有的排序算法都不能用了。 这里适合的算法是分治法,也就是使用快速排序。因为这道题的一个特点是只需要得到第k小的数字,而并没有说要对所有元素进行排序。如果我们把所有小于某个元素的元素都置于其左侧,且正 阅读全文
posted @ 2024-03-05 21:04 SaTsuki26681534 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 题目描述 看起来很简单,但是n的取值范围是<=50,结果有可能会很大,一般的算法AC不了。 题解上说要用一种叫做高精度运算的算法: 24.cnblogs.com/blog/3213233/202403/3213233-20240302211217307-1826622717.png) 这里的高精度算 阅读全文
posted @ 2024-03-02 23:14 SaTsuki26681534 阅读(3) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 10 下一页