12 2022 档案

摘要:组合 题目 中等 class Solution { List<List<Integer>> result = new ArrayList<>(); LinkedList<Integer> path = new LinkedList<>(); public List<List<Integer>> co 阅读全文
posted @ 2022-12-31 11:32 幻梦翱翔 阅读(28) 评论(0) 推荐(0) 编辑
摘要:二叉树的递归遍历 前序 中序 后序 简单 // 前序遍历·递归·LC144_二叉树的前序遍历 class Solution { public List<Integer> preorderTraversal(TreeNode root) { List<Integer> result = new Arr 阅读全文
posted @ 2022-12-10 14:23 幻梦翱翔 阅读(22) 评论(0) 推荐(0) 编辑
摘要:用栈实现队列 题目 简单 把 pop() 和 peek() 中可复用的部分提取出来 class MyQueue { Stack<Integer> stackIn; Stack<Integer> stackOut; /** Initialize your data structure here. */ 阅读全文
posted @ 2022-12-06 10:58 幻梦翱翔 阅读(27) 评论(0) 推荐(0) 编辑
摘要:反转字符串 题目 简单 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 阅读全文
posted @ 2022-12-03 15:50 幻梦翱翔 阅读(27) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
主题色彩