上一页 1 2 3 4 5 6 7 8 9 ··· 36 下一页
摘要: class Solution { List<String> res = new LinkedList<>(); public List<String> generateParenthesis(int n) { if(n == 0) return null; dfs("",0,0,n); return 阅读全文
posted @ 2020-07-28 17:48 浅滩浅 阅读(81) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/single-number/submissions/ 要求O(1)的空间复杂度,不用排序。 动画演示: class Solution { //位运算(异或) public int singleNumber(int[] num 阅读全文
posted @ 2020-07-27 16:11 浅滩浅 阅读(61) 评论(0) 推荐(0)
摘要: class Solution { //全排列问题 Set<List<Character>> res = new HashSet<>(); public String[] permutation(String s) { char []strs = s.toCharArray(); int len = 阅读全文
posted @ 2020-07-26 19:29 浅滩浅 阅读(87) 评论(0) 推荐(0)
摘要: 排序: class Solution { public boolean isStraight(int[] nums) { Arrays.sort(nums); int zero = 0; int needZero = 0; if(nums[0] == 0) zero++; for(int i=1;i 阅读全文
posted @ 2020-07-25 16:13 浅滩浅 阅读(221) 评论(0) 推荐(0)
摘要: 题解:利用String数组自定义排序(字符拼接进行比较),之前还想着全排序。。。。。。。。。 class Solution { public String minNumber(int[] nums) { String []arr = new String[nums.length]; for(int 阅读全文
posted @ 2020-07-24 19:07 浅滩浅 阅读(75) 评论(0) 推荐(0)
摘要: class Solution { public int lastRemaining(int n, int m) { //模拟法超时 int pos = 0;//长度为1时候安全的下标 //反推的过程 //从i-1个人到i人的安全序号的变化 //正过程: //1、下标为j+1的成为数组头,j前面的人加 阅读全文
posted @ 2020-07-24 18:17 浅滩浅 阅读(100) 评论(0) 推荐(0)
摘要: 思路:用一个栈进行模拟,当栈不为空且栈顶元素与出栈数组的元素相等时,元素出栈,出栈元素后移,继续与栈顶元素对比,如此反复 class Solution { public boolean validateStackSequences(int[] pushed, int[] popped) { Stac 阅读全文
posted @ 2020-07-23 21:51 浅滩浅 阅读(106) 评论(0) 推荐(0)
摘要: 解题:前序遍历加上筛选 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = 阅读全文
posted @ 2020-07-23 20:23 浅滩浅 阅读(129) 评论(0) 推荐(0)
摘要: 平衡树:对于每一个节点它的左右子树深度差不能超过1 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode( 阅读全文
posted @ 2020-07-23 19:12 浅滩浅 阅读(104) 评论(0) 推荐(0)
摘要: 二叉搜索树:左子树的值小于右子树的值(不会出现重复的情况) /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeN 阅读全文
posted @ 2020-07-23 18:23 浅滩浅 阅读(104) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 36 下一页
点击右上角即可分享
微信分享提示