随笔分类 -  工作模式 / 手撕代码

算法题相关
摘要:class Solution { public TreeNode sortedArrayToBST(int[] nums) { return sortedArrayToBST(nums, 0, nums.length); } public TreeNode sortedArrayToBST(int[ 阅读全文
posted @ 2024-12-11 10:17 墨羽寻觅 阅读(8) 评论(0) 推荐(0) 编辑
摘要:哈希表 有效的字母异位词 /** * 242. 有效的字母异位词 字典解法 * 时间复杂度O(m+n) 空间复杂度O(1) */ class Solution { public boolean isAnagram(String s, String t) { int[] record = new in 阅读全文
posted @ 2024-11-28 18:33 墨羽寻觅 阅读(9) 评论(0) 推荐(0) 编辑
摘要:链表篇 跳-移除链表元素-203-力扣 给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val == val 的节点,并返回 新的头节点 。 示例 1: 输入:head = [1,2,6,3,4,5,6], val = 6 输出:[1,2,3,4,5] 示例 阅读全文
posted @ 2024-11-28 18:33 墨羽寻觅 阅读(8) 评论(0) 推荐(0) 编辑
摘要:字符串 跳-反转字符串 我写的代码 class Solution { public void reverseString(char[] s) { int len = s.length; char temp; int left = 0, right = len-1; while (left < rig 阅读全文
posted @ 2024-11-28 18:31 墨羽寻觅 阅读(4) 评论(0) 推荐(0) 编辑
摘要:栈和队列 用栈实现队列 class MyQueue { // 定义全局变量 Stack<Integer> stackIn; Stack<Integer> stackOut; public MyQueue() { // 通过使用两个栈来模拟队列 stackIn = new Stack<>(); // 阅读全文
posted @ 2024-11-27 17:40 墨羽寻觅 阅读(15) 评论(0) 推荐(0) 编辑
摘要:数组篇 跳-二分查找-704-力扣 class Solution { public int search(int[] nums, int target) { if (nums == null || nums.length == 0) return -1; if (target < nums[0] | 阅读全文
posted @ 2024-11-02 15:58 墨羽寻觅 阅读(12) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示