2022年11月3日 #

leetcode - 234. 回文链表

摘要: 234. 回文链表 public boolean isPalindrome(ListNode head) { return twoPoint(head); //return withStack(head); } //找中点, 反转后一部分链表 public boolean twoPoint(List 阅读全文

posted @ 2022-11-03 16:47 老菜农 阅读(19) 评论(0) 推荐(0) 编辑

leetcode - 94. 二叉树的中序遍历

摘要: 94. 二叉树的中序遍历 List<Integer> inorder = new ArrayList<>(); public List<Integer> inorderTraversal(TreeNode root) { withStack(root); return inorder; } //递归 阅读全文

posted @ 2022-11-03 15:02 老菜农 阅读(6) 评论(0) 推荐(0) 编辑

leetcode - 617. 合并二叉树

摘要: 617. 合并二叉树 class Solution { //迭代 public TreeNode mergeTreesWithStack(TreeNode root1, TreeNode root2) { //如果当前root左右子树有一个是空的, 直接把非空的那个返回 if(root1 == nu 阅读全文

posted @ 2022-11-03 13:49 老菜农 阅读(15) 评论(0) 推荐(0) 编辑

导航