算法
造梦灬烟花
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
树的前中后序
前序就是根左右,中序就是左根右,后序就是左右根 树结构 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } ...原创 2020-04-14 21:55:17 · 196 阅读 · 0 评论 -
C++大数乘法
c++版本的大数乘法 #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<vector> #include<set> #include<cmath> #include<cstring> #in...原创 2020-03-30 17:30:40 · 200 阅读 · 0 评论 -
阿里第一轮笔试第二题
第一题完全不会,第二题被自己蠢哭,递增的字符串只需要判断前一个的最后一个字符和第二个子串的第一个字符就可以了,我居然写成了两个字符串比大小,唉,可能这就是命吧。深搜加记忆性递归应该可以满分(我居然被一个比较函数搞成了零分,心态炸裂)。 #include<iostream> #include<string> #include<algorithm> #include...原创 2020-03-20 19:48:57 · 263 阅读 · 0 评论 -
dp模板(01背包 完全背包 最长子序列)
01背包 for(int i=1;i<=n;i++) { for(int c=m;c>=0;c--) { if(c>=w[i]) f[c]=max(f[c],f[c-w[i]]+v[i]); } } 完全背包 for(int i=1;i<=n;i++) { for(int c=0;c<=m;c++) ...原创 2020-03-14 15:45:42 · 137 阅读 · 0 评论 -
二叉树的遍历(中序后序转层序和前序)
Sample Input: 7 2 3 1 5 7 6 4 1 2 3 4 5 6 7 Sample Output: 4 1 6 3 5 7 2 先转换成前序,然后在每一个节点带一个index,最后排序一下就是层序的结果了 #include<iostream> #include<string> #include<algorithm> #include<cs...原创 2020-02-09 16:13:56 · 568 阅读 · 0 评论
分享