Fork me on github
摘要: 回溯,全局变量 import java.util.ArrayList; import java.util.List; /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode le 阅读全文
posted @ 2020-08-26 23:04 zjy4fun 阅读(104) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; /* 层次遍历的变形 */ class Solution { public List<List<Integer>> zigzagLevelOrder(TreeNode root) { List<List<Integer>> res = new ArrayLis 阅读全文
posted @ 2020-08-26 22:25 zjy4fun 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 思路:找序列中最小的那个数字,然后递增检查。 import java.util.HashSet; import java.util.Set; class Solution { public int longestConsecutive(int[] nums) { Set<Integer> set = 阅读全文
posted @ 2020-08-26 21:22 zjy4fun 阅读(172) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } * 阅读全文
posted @ 2020-08-26 21:15 zjy4fun 阅读(92) 评论(0) 推荐(0) 编辑