摘要: 在分析 Java 并发包 java.util.concurrent 源码的时候,少不了需要了解 AbstractQueuedSynchronizer(以下简写 AQS)这个抽象类,因为它是 Java 并发包的基础工具类,是实现 ReentrantLock、CountDownLatch、Semapho 阅读全文
posted @ 2024-04-05 22:24 szw_sama 阅读(47) 评论(0) 推荐(0)
摘要: 题349. 两个数组的交集 解法1 set去重、contains比较 class Solution { public int[] intersection(int[] nums1, int[] nums2) { Set<Integer> set1 = new HashSet<>();//使用set集 阅读全文
posted @ 2023-01-25 13:07 szw_sama 阅读(22) 评论(0) 推荐(0)
摘要: 在此留言 阅读全文
posted @ 2023-01-25 03:08 szw_sama 阅读(19) 评论(12) 推荐(0)
摘要: 代码随想录 | Day6-2 | LC 01两数之和、242. 有效的字母异位词 1. 两数之和 解法1,利用HashMap(map.get(Key))实现数的存储和输出 class Solution { public int[] twoSum(int[] nums, int target) { Map<Integer,Integer> map = new HashMap<>() 阅读全文
posted @ 2023-01-24 17:59 szw_sama 阅读(30) 评论(0) 推荐(0)
摘要: 题349. 两个数组的交集 解法1 set去重、contains比较 class Solution { public int[] intersection(int[] nums1, int[] nums2) { Set<Integer> set1 = new HashSet<>();//使用set集 阅读全文
posted @ 2023-01-24 14:27 szw_sama 阅读(17) 评论(0) 推荐(0)
摘要: 题704. 二分查找 题目 解法1:纯遍历 class Solution { public int search(int[] nums, int target) { for (int i = 0; i < nums.length; i++) { if (nums[i] == target) retu 阅读全文
posted @ 2023-01-24 14:23 szw_sama 阅读(18) 评论(0) 推荐(0)
摘要: 题977. 有序数组的平方 解法1:暴力 class Solution { public int[] sortedSquares(int[] nums) { for (int i = 0; i <nums.length ; i++) { nums[i]=nums[i]*nums[i]; } Arra 阅读全文
posted @ 2023-01-24 14:23 szw_sama 阅读(19) 评论(0) 推荐(0)
摘要: 题203. 移除链表元素 class Solution { public ListNode removeElements(ListNode head, int val) { if (head == null) { return null; } ListNode xuni_tou_node = new 阅读全文
posted @ 2023-01-24 14:22 szw_sama 阅读(15) 评论(0) 推荐(0)