01 2024 档案

摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For 阅读全文
posted @ 2024-01-19 23:56 MarkLeeBYR 阅读(3) 评论(0) 推荐(0) 编辑
摘要:public List<Integer> postorderTraversal(TreeNode root) { List<Integer> list = new ArrayList<>(); if (root == null) return list; Stack<TreeNode> stack 阅读全文
posted @ 2024-01-04 17:47 MarkLeeBYR 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Solution 1://非递归 public List<Integer> preorderTraversal(TreeNode root) { List<Integer> result = new ArrayList<>(); if (root == null) { return result; 阅读全文
posted @ 2024-01-04 17:45 MarkLeeBYR 阅读(3) 评论(0) 推荐(0) 编辑
摘要:输入321,需要输出123 public static int reverse(int x) { int res = 0; while (x != 0) { // 下一步要res*10,所以这一步要保证res*10不大于 Integer.MAX_VALUE if (Math.abs(res) > I 阅读全文
posted @ 2024-01-04 17:29 MarkLeeBYR 阅读(6) 评论(0) 推荐(0) 编辑
摘要:和题目108类似:108是数组 https://www.cnblogs.com/MarkLeeBYR/p/16906818.html public TreeNode sortedListToBST(ListNode head) { if (head == null) { return null; } 阅读全文
posted @ 2024-01-04 16:25 MarkLeeBYR 阅读(4) 评论(0) 推荐(0) 编辑