随笔分类 -  每日刷题记录

上一页 1 2 3
为了找工作做准备
2024/12/9 【哈希表】LeetCode 15.三数之和 【❌】知识点:sort和sorted函数
摘要:15. 三数之和 - 力扣(LeetCode) 代码随想录 (programmercarl.com) 方法一:双指针法 class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: res = [] nums.sort 阅读全文
posted @ 2024-12-13 20:59 axuu 阅读(11) 评论(0) 推荐(0)
2024/12/8 【哈希表】LeetCode 383.赎金信【√】知识点:all函数,ord函数,Collections.Counter,count函数,str.count函数
摘要:383. 赎金信 - 力扣(LeetCode) 代码随想录 方法1:数组 all(...) all 函数用于检查迭代器中的所有条件是否都为 True。 如果任意一个条件为 False,all 会返回 False。 方法2:使用defaultdict 我的代码: 代码随想录的代码: 方法3:使用字典 阅读全文
posted @ 2024-12-13 09:48 axuu 阅读(24) 评论(0) 推荐(0)
2024/12/7【哈希表】 LeetCode453 四数相加II ,知识点:defaultdict,lambda函数,dict的get函数
摘要:454. 四数相加 II - 力扣(LeetCode) 代码随想录 (programmercarl.com) 本题解题步骤: 首先定义 一个unordered_map(在python中为字典),key放a和b两数之和,value 放a和b两数之和出现的次数。 遍历大A和大B数组,统计两个数组元素之和 阅读全文
posted @ 2024-12-12 17:02 axuu 阅读(68) 评论(0) 推荐(0)
2024/12/6 【哈希表】LeetCode1.两数之和 【√】
摘要:解法1:暴力解法 class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): des = target - nums[i] if des in nums 阅读全文
posted @ 2024-12-06 13:43 axuu 阅读(14) 评论(0) 推荐(0)
2024/12/5 【哈希表】202 快乐数
摘要:202. 快乐数 - 力扣(LeetCode) 解法1: (1)把数字n转换为字符串,从而得到每一位的数值。 事先不知道数字n有多少位。 (2)把每一次求平方和得到的数存到集合中,从而避免数字重复导致的循环。 class Solution: def calSquare(self, num): str 阅读全文
posted @ 2024-12-06 12:44 axuu 阅读(25) 评论(0) 推荐(0)
2024/12/4 【哈希表】LeetCode 349.两个数组的交集 【√】
摘要:文心一言: Python 的集合类型有一个 & 操作符,可以用来计算两个集合的交集。 class Solution: def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]: nums1_set = set(nu 阅读全文
posted @ 2024-12-04 20:25 axuu 阅读(12) 评论(0) 推荐(0)
2024/12/3 【哈希表】 LeetCode 242.有效的字母异位词 【x】
摘要:题目链接:https://leetcode.cn/problems/valid-anagram/description/ 解法1: class Solution: def isAnagram(self, s: str, t: str) -> bool: record = [0]*26 for i i 阅读全文
posted @ 2024-12-03 21:09 axuu 阅读(12) 评论(0) 推荐(0)
2024/12/3 【哈希表】
摘要:https://www.programmercarl.com/%E5%93%88%E5%B8%8C%E8%A1%A8%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.html#%E5%B8%B8%E8%A7%81%E7%9A%84%E4%B8%89%E7%A7%8D%E5%9 阅读全文
posted @ 2024-12-03 20:58 axuu 阅读(17) 评论(0) 推荐(0)
2024/12/2【链表】LeetCode 142 环形链表 II 【X】
摘要:题目链接: https://leetcode.cn/problems/linked-list-cycle-ii/description/ 题解链接: https://www.programmercarl.com/0142.%E7%8E%AF%E5%BD%A2%E9%93%BE%E8%A1%A8II. 阅读全文
posted @ 2024-12-03 11:30 axuu 阅读(15) 评论(0) 推荐(0)
2024/12/1 【链表】 LeetCode 面试题 02.07. 链表相交
摘要:面试题 02.07. 链表相交 - 力扣(LeetCode) 文心一言: 首先,getIntersectionNode 方法中调用了 self.getIntersectionNode2(headA, headB) 等,但这些调用没有使用它们的返回值。getIntersectionNode2 方法返回 阅读全文
posted @ 2024-12-02 00:07 axuu 阅读(18) 评论(0) 推荐(0)
2024/11/27 【链表】LeetCode 24 两两交换链表中的节点 & LeetCode 19 删除链表的倒数第N个节点
摘要:24. 两两交换链表中的节点 - 力扣(LeetCode) 代码随想录 递归方式:没有想到 # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.va 阅读全文
posted @ 2024-11-27 09:45 axuu 阅读(18) 评论(0) 推荐(0)
2024/11/26【链表】LeetCode 206 反转链表
摘要:206. 反转链表 - 力扣(LeetCode) 代码随想录 解法1:双指针法 解法2:递归法(代码如下所示) # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): 阅读全文
posted @ 2024-11-26 16:55 axuu 阅读(17) 评论(0) 推荐(0)
2024/11/25 LeetCode707.设计链表
摘要:解法一:单链表解法 1 #单链表法 2 class ListNode: 3 def __init__(self, val=0, next=None): 4 self.val = val 5 self.next = next 6 7 class MyLinkedList: 8 9 def __init 阅读全文
posted @ 2024-11-25 19:19 axuu 阅读(28) 评论(0) 推荐(0)
2024/11/24 链表
摘要:链表 1.类型 (1)单链表 (2)双链表 (3)循环链表 2.链表在内存的存储方式 数组是在内存中是连续分布的,但是链表在内存中可不是连续分布的,而是散乱分布在内存中的某地址上,分配机制取决于操作系统的内存管理。 链表是通过指针域的指针链接在内存中各个节点。 3.链表的定义 定义链表节点方式 Py 阅读全文
posted @ 2024-11-24 19:42 axuu 阅读(22) 评论(0) 推荐(0)

上一页 1 2 3