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
阅读全文
摘要:public List<Integer> postorderTraversal(TreeNode root) { List<Integer> list = new ArrayList<>(); if (root == null) return list; Stack<TreeNode> stack
阅读全文
摘要:Solution 1://非递归 public List<Integer> preorderTraversal(TreeNode root) { List<Integer> result = new ArrayList<>(); if (root == null) { return result;
阅读全文
摘要:输入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
阅读全文
摘要:和题目108类似:108是数组 https://www.cnblogs.com/MarkLeeBYR/p/16906818.html public TreeNode sortedListToBST(ListNode head) { if (head == null) { return null; }
阅读全文