自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 LeetCode:1605. Find Valid Matrix Given Row and Column Sums

1605. Find Valid Matrix Given Row and Column Sumsvector<vector<int>> restoreMatrix(vector<int> &rowSum, vector<int> &colSum) { int m = rowSum.size(), n = colSum.size(); vector<vector<int>> result(m, ve

2021-03-03 10:46:19 130

原创 0-1背包问题

给定n个重量为w 1 w_1w1​,w 2 w_2w2​,w 3 w_3w3​,…,w n w_nwn​,价值为v 1 v_1v1​,v 2 v_2v2​,v 3 v_3v3​,…,v n v_nvn​的物品和容量为C CC的背包,求这个物品中一个最有价值的子集,使得在满足背包的容量的前提下,包内的总价值最大0-1背包问题指的是每个物品只能使用一次int knapsack(vector<int> w, vector<int> val, int n) { int si

2021-01-15 10:29:40 133

原创 1,2,5,10元零钱组合成n元方案数

int nums_change_combine(int n) { int changes[] = {1, 2, 5, 10}; // dp(n,i): 使用下标为i以及之前的零钱组成n元的组合数 // dp(n,i)=dp(n,i-1)+dp(n-val(i),i) int dp[n + 1][4]; for (int i = 0; i <= n; ++i) { for (int j = 0; j < 4; ++j) { .

2021-01-14 09:59:24 1135

原创 最近公共祖先

bool get_node_path(TreeNode* root,TreeNode* n, vector<TreeNode*> &path){ if(root==NULL)return false; if(root==n || get_node_path(root->left,n,path) || get_node_path(root->right,n,path)){ path.emplace_back(root); ret.

2021-01-12 12:23:47 79

原创 并查集(union-find)

leetcode-1202.Smallest String With Swapsclass Solution {public: int _find(unordered_map<int, pair<int, int>>& parents, int node) { while (parents.at(node).first !=...

2020-03-26 10:42:06 110

原创 连续质数序列

返回<=n的所有质数// 埃拉托色尼的筛子vector<int> sieve(int n) { vector<int> nums, result; for (int i = 0; i <= n; ++i)nums.emplace_back(i); for (int i = 2; i < pow(n, 0.5); ++i) {...

2020-03-22 11:33:46 832

原创 最大公约数

蛮力法 // greatest common divisorint gcd(int m, int n) { int result = min(m, n); if (result == 0)return max(m, n); while (result--) { if (m % result == 0 && n % result == 0...

2020-03-22 11:15:27 141

原创 扔鸡蛋问题

问题:有m层的高楼,n个鸡蛋,需要扔几次鸡蛋才能确定使鸡蛋落地后变碎的最低楼层,鸡蛋如果没碎可以重复使用int minTimes(int m, int n) { vector<vector<int>> dp(m + 1, vector<int>(n + 1)); int fk; for (int j = 1; j <= n;...

2020-03-20 22:41:48 171

原创 最大子数组

问题:给定一个数组,有正有负,求它的一个子数组,使得数组里的元素和最大解:分治法ector<int> max_subarray(vector<int> &v,int low,int mid,int high) { int sum=0,max_left_sum=-INT_MAX,max_right_sum=-INT_MAX,start=low,end...

2020-03-20 20:33:40 136

原创 最长回文子串

动态规划,时间复杂度O(n^2)string longestPalindrome(const string &str) { int n = str.length(); int start = 0; int length = 1; bool dp[n][n]; for (int j = 0; j < n; ++j) { fo...

2020-03-20 15:07:18 93

原创 编辑距离

递归法int editDistance(string &word1, string &word2, int i, int j) { if (i == -1)return j + 1; if (j == -1)return i + 1; if (word1[i] == word2[j])return editDistance(word1, word2, ...

2020-03-20 15:03:21 108

原创 排列组合

1. 在 tomcat/bin/startup.bat 文件末尾添加 `pause` 后重新启动,可以看到错误原因,一般是没有设置JAVA_HOME 环境变量,错误显示:Neither the JAVA_HOME nor the JRE_HOME environment variable is definedAt least one of these environment varia

2020-03-20 14:42:26 135

原创 tomcat启动闪退

tomcat启动闪退

2017-07-08 16:30:31 536

原创 ubuntu16.04安装SSH和Samba

ubuntu安装SSH和Samba

2017-07-06 11:03:11 1433

原创 VirtualBox无法新建64位系统、VMware错误:VMware Workstation 与 Device/Credential Guard 不兼容

解决无法创建虚拟机

2017-07-05 19:26:47 1053

转载 ubuntu16开启root账号登录

ubuntu16桌面版开启root账户登录mesg:ttyname failed:Inappropriate ioctl for device问题解决

2017-06-30 16:14:36 953

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除