![](https://img-blog.csdnimg.cn/0c9180bc1e314324acf8c7a71c2ec728.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
LeetCode
刷题
linghugoogle1
Show me the code.
展开
-
LeetCode - 拓扑排序
207. 课程表class Solution {public: bool canFinish(int nums, vector<vector<int>>& pres) { if (pres.size() == 0 || pres[0].size() == 0) { return true; } vector<vector<int>> paths(nums);原创 2021-09-13 23:20:32 · 263 阅读 · 0 评论 -
DP字符串
1、单字符串/数组模板一般dp[i]表示以i结尾的子序列,,最终结果为dp[n-1]。53. 最大子序和class Solution {public: int maxSubArray(vector<int>& nums) { int n = nums.size(); vector<int> dp(n, 0); for (int i=0; i<n; i++) { dp[原创 2021-09-06 23:36:56 · 502 阅读 · 0 评论 -
背包问题C++实现
1、01背包:只能用一次1.1、是否存在416. Partition Equal Subset Sumclass Solution {public: bool canPartition(vector<int>& nums) { int n=nums.size(); int sum=0; for (int i=0;i<n;i++) { sum+=nums[i]; }原创 2021-09-06 18:01:51 · 1144 阅读 · 0 评论 -
merge-sort && quick-sort
merge sortreference:https://blog.csdn.net/zpznba/article/details/83745205It's post-order traversal.#include <iostream>#include <vector>using namespace std;void mergeHelper(vector<int> &nums, int left, int mid, int ..原创 2021-08-24 00:53:47 · 112 阅读 · 0 评论