好想找工作
好想找工作
全部文章
分类
题解(43)
归档
标签
去牛客网
登录
/
注册
每天进步一点点
算法总结,刷题总结,基础总结,各种总结
全部文章
(共43篇)
JZ54 字符流中第一个不重复的字符
解法一:HashMap+ArrayList 基本思路 用HashSet记录出现过至少一次的值,用ArrayList记录只出现过一次的值。 insert每次在HashSet中查找 ch,如果没有,那么就往ArrayList中添加;如果有,就从ArrayList中删除 ch。(可能出现ArrayLis...
Java
HashMap
ArrayList
Queue
HashSet
2020-06-16
0
611
JZ50 数组中重复的数字
解法一: HashSet import java.util.*; public class Solution { public boolean duplicate(int numbers[],int length,int [] duplication) { duplicati...
Java
去重
HashSet
2020-06-15
0
618
JZ38 二叉树的深度,两种解法
解法一:一行代码 public class Solution { public int TreeDepth(TreeNode root) { return root==null? 0:Math.max(TreeDepth(root.left),TreeDepth(root.r...
Java
递归
层序遍历
宽度优先遍历
队列
BFS
2020-06-15
2
654
JZ5 用两个栈实现队列
解法一:负负得正 import java.util.Stack; public class Solution { Stack<Integer> stack1 = new Stack<Integer>(); Stack<Integer> stack...
Java
栈
队列
2020-06-15
0
576
JZ18 二叉树的镜像,递归&迭代
解法一:递归 public class Solution { public void Mirror(TreeNode root) { root=reverse(root); } TreeNode reverse(TreeNode root){ ...
Java
递归
二叉树
迭代
2020-06-15
0
640
JZ9 变态跳台阶,四种解法
解法一:暴力破解 public class Solution { public int JumpFloorII(int target) { if(target<3) return target; int[] ans=new int[target+1]; ...
Java
动态规划
移位
2020-06-15
1
674
JZ29 最小的K个数,大根堆
解法一:使用PriorityQueue import java.util.*; public class Solution { public ArrayList<Integer> GetLeastNumbers_Solution(int [] input, int k) { ...
最值
Java
递归
层序遍历
满二叉树
大根堆
优先队列
2020-06-09
0
660
JZ13 调整数组使奇数位于偶数前面,两种解法
解法一:愚蠢的复制粘贴, 21 ms public class Solution { public void reOrderArray(int [] array) { if(array==null||array.length<2) return; int...
Java
奇偶
数组
2020-06-09
0
527
JZ20 包含min函数的栈, 辅助栈
解法一:同步辅助栈 import java.util.Stack; public class Solution { Stack<Integer> stack=new Stack<>(); Stack<Integer> helper=new S...
最值
Java
辅助栈
栈
2020-06-08
0
542
JZ24 二叉树中和为某一值的路径,dfs
dfs1 public class Solution { public ArrayList<ArrayList<Integer>> FindPath(TreeNode root,int target) { ans=new ArrayList<&g...
dfs
Java
递归
二叉树
2020-06-08
0
537
首页
上一页
1
2
3
4
5
下一页
末页