摘要: 又看不懂的代码可以在底下评论,我都会回复的 阅读全文
posted @ 2022-03-09 15:51 现在开始努力 阅读(16) 评论(0) 推荐(0)
摘要: 662. 二叉树最大宽度(优化解法,防止正常标记的id数超过int范围(全是右子树)) List<Integer> ls = new ArrayList<>(); // 记录每一层的最左节点初始id public int widthOfBinaryTree(TreeNode root) { retu 阅读全文
posted @ 2022-03-09 13:31 现在开始努力 阅读(20) 评论(0) 推荐(0)
摘要: 题目描述 给你一个食物网,你要求出这个食物网中最大食物链的数量。 (这里的“最大食物链”,指的是生物学意义上的食物链,即最左端是不会捕食其他生物的生产者,最右端是不会被其他生物捕食的消费者。) Delia 非常急,所以你只有 1 秒的时间。 由于这个结果可能过大,你只需要输出总数模上 8011200 阅读全文
posted @ 2022-03-09 10:41 现在开始努力 阅读(119) 评论(0) 推荐(0)
摘要: 1.JZ33 二叉搜索树的后序遍历序列 public boolean VerifySquenceOfBST(int [] sequence) { if(sequence == null || sequence.length == 0) { return false; } return process 阅读全文
posted @ 2022-02-28 15:09 现在开始努力 阅读(18) 评论(0) 推荐(0)
摘要: 1.JZ23 链表中环的入口结点 public ListNode EntryNodeOfLoop(ListNode pHead) { if(pHead == null || pHead.next == null || pHead.next.next == null) { return null; } 阅读全文
posted @ 2022-02-25 11:56 现在开始努力 阅读(24) 评论(0) 推荐(0)
摘要: 1.JZ13 机器人的运动范围 int ans = 0; public int movingCount(int threshold, int rows, int cols) { boolean dp[][] = new boolean[rows][cols]; process(dp,threshol 阅读全文
posted @ 2022-02-24 11:00 现在开始努力 阅读(44) 评论(0) 推荐(0)
摘要: 1.JZ3 数组中重复的数字 public int duplicate (int[] numbers) { int L = 0; while(L < numbers.length) { if(numbers[L] == L) { L ++; }else if(numbers[numbers[L]] 阅读全文
posted @ 2022-02-23 17:07 现在开始努力 阅读(41) 评论(0) 推荐(0)
摘要: 148.排序链表 public ListNode sortList(ListNode head) { ListNode cur = head; int length = 0; while(cur != null) { cur = cur.next; length ++; } ListNode h = 阅读全文
posted @ 2022-02-18 15:54 现在开始努力 阅读(40) 评论(0) 推荐(0)
摘要: 136.只出现一次的数字 public int singleNumber(int[] nums) { int ans = 0; for(int i : nums) { ans ^= i; } return ans; } 138.复制带随机指针的链表 public Node copyRandomLis 阅读全文
posted @ 2022-02-17 15:36 现在开始努力 阅读(29) 评论(0) 推荐(0)
摘要: 128.最长连续序列 public int longestConsecutive(int[] nums) { int len = 0; HashMap<Integer,Integer> hm = new HashMap<>(); for(int i : nums) { if(!hm.contains 阅读全文
posted @ 2022-02-16 15:29 现在开始努力 阅读(25) 评论(0) 推荐(0)