02 2022 档案
摘要:1.JZ33 二叉搜索树的后序遍历序列 public boolean VerifySquenceOfBST(int [] sequence) { if(sequence == null || sequence.length == 0) { return false; } return process
阅读全文
摘要:1.JZ23 链表中环的入口结点 public ListNode EntryNodeOfLoop(ListNode pHead) { if(pHead == null || pHead.next == null || pHead.next.next == null) { return null; }
阅读全文
摘要:1.JZ13 机器人的运动范围 int ans = 0; public int movingCount(int threshold, int rows, int cols) { boolean dp[][] = new boolean[rows][cols]; process(dp,threshol
阅读全文
摘要:1.JZ3 数组中重复的数字 public int duplicate (int[] numbers) { int L = 0; while(L < numbers.length) { if(numbers[L] == L) { L ++; }else if(numbers[numbers[L]]
阅读全文
摘要:148.排序链表 public ListNode sortList(ListNode head) { ListNode cur = head; int length = 0; while(cur != null) { cur = cur.next; length ++; } ListNode h =
阅读全文
摘要:136.只出现一次的数字 public int singleNumber(int[] nums) { int ans = 0; for(int i : nums) { ans ^= i; } return ans; } 138.复制带随机指针的链表 public Node copyRandomLis
阅读全文
摘要:128.最长连续序列 public int longestConsecutive(int[] nums) { int len = 0; HashMap<Integer,Integer> hm = new HashMap<>(); for(int i : nums) { if(!hm.contains
阅读全文
摘要:124.二叉树的最大路径和 public int maxPathSum(TreeNode root) { if(root == null) { return 0; } return process(root).max; } public Info process(TreeNode root) { i
阅读全文
摘要:188.买卖股票的最佳时机4 public int maxProfit(int k, int[] prices) { if (prices == null || prices.length == 0) { return 0; } int N = prices.length; if (k >= N /
阅读全文
摘要:116.填充每个节点的下一个右侧节点 public Node connect(Node root) { if(root == null) { return null; } MyQueue myQueue = new MyQueue(); myQueue.add(root); while(!myQue
阅读全文

浙公网安备 33010602011771号