12 2022 档案
摘要:组合 题目 中等 class Solution { List<List<Integer>> result = new ArrayList<>(); LinkedList<Integer> path = new LinkedList<>(); public List<List<Integer>> co
阅读全文
摘要:二叉树的递归遍历 前序 中序 后序 简单 // 前序遍历·递归·LC144_二叉树的前序遍历 class Solution { public List<Integer> preorderTraversal(TreeNode root) { List<Integer> result = new Arr
阅读全文
摘要:用栈实现队列 题目 简单 把 pop() 和 peek() 中可复用的部分提取出来 class MyQueue { Stack<Integer> stackIn; Stack<Integer> stackOut; /** Initialize your data structure here. */
阅读全文
摘要:反转字符串 题目 简单 class Solution { public void reverseString(char[] s) { int l = 0; int r = s.length - 1; while (l < r) { s[l] ^= s[r]; //构造 a ^ b 的结果,并放在 a
阅读全文