摘要: 01背包只不过是 每一组的个数为1,分组背包每一组的个数为s[i] 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 const int N=110; 5 int f[N]; 6 int v[N][N],w[N][N],s[N]; 7 int 阅读全文
posted @ 2020-03-19 10:34 Jinxiaobo0509 阅读(151) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 int maxSubArray(vector<int>& nums) 5 { 6 int n = nums.size(); 7 vector<int> dp(n + 5,0); 8 dp[0] = nums[0]; 9 int res 阅读全文
posted @ 2020-03-18 23:02 Jinxiaobo0509 阅读(92) 评论(0) 推荐(0)
摘要: 思路跟51题一模一样 1 class Solution 2 { 3 vector<vector<string>> res; 4 vector<string> temp;//临时路径 5 vector<bool> col,m,s;//列,主对角线,副对角线 6 int n; 7 public: 8 i 阅读全文
posted @ 2020-03-18 22:50 Jinxiaobo0509 阅读(104) 评论(0) 推荐(0)
摘要: (按行枚举) O(n!)说明:对角线dg[u + i],反对角线udg[n - u + i]中的下标表示的是截距(u, i)即(x, y)对角线y = x + b, 截距b = y - x(因为我们要把b当做数组下标,所以b不能是负的,所以我们+n,保证是结果是正的) 反对角线y = -x + b, 阅读全文
posted @ 2020-03-18 22:46 Jinxiaobo0509 阅读(102) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 double solve(double x, int n) //其中n为非负数 4 { 5 if(n == 0) return 1; 6 double res = 1; 7 for(int i = 1;i <= n;i ++) res *= x; 8 r 阅读全文
posted @ 2020-03-18 18:37 Jinxiaobo0509 阅读(119) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 vector<vector<string>> groupAnagrams(vector<string>& strs) 5 { 6 vector<vector<string>> res; 7 unordered_map<string,v 阅读全文
posted @ 2020-03-18 18:14 Jinxiaobo0509 阅读(75) 评论(0) 推荐(0)
摘要: 1 //1、先转置 2 //2、第一列与最后一列交换、第二列与倒数第二列交换、... 3 class Solution 4 { 5 public: 6 void rotate(vector<vector<int>>& matrix) 7 { 8 int n = matrix.size(); 9 fo 阅读全文
posted @ 2020-03-18 18:04 Jinxiaobo0509 阅读(127) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 vector<vector<int>> ans; 4 vector<int> temp; 5 vector<bool> st; 6 public: 7 vector<vector<int>> permuteUnique(vector<int>& nums 阅读全文
posted @ 2020-03-18 17:19 Jinxiaobo0509 阅读(99) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 vector<vector<int>> ans; 4 vector<int> temp; 5 vector<bool> st; 6 public: 7 vector<vector<int>> permute(vector<int>& nums) 8 { 阅读全文
posted @ 2020-03-18 16:53 Jinxiaobo0509 阅读(102) 评论(0) 推荐(0)
摘要: 1 //"12" * "34" 2 // 1 2 3 // *3 4 4 // ———————— 5 // 4 8 6 // 3 6 7 // ———————— 8 // 4 0 8 9 // ***注意第二个字符串在第一层循环*** 10 11 class Solution 12 { 13 pub 阅读全文
posted @ 2020-03-18 16:43 Jinxiaobo0509 阅读(128) 评论(0) 推荐(0)