
LeetCode精选
文章平均质量分 68
在LeetCode刷题中进行学习
Syntax_CD
这个作者很懒,什么都没留下…
展开
-
389. 找不同 (Python3)
参考:原创 2024-01-25 00:01:12 · 381 阅读 · 0 评论 -
283. 移动零 (Python3)
参考:原创 2024-01-24 18:56:38 · 418 阅读 · 1 评论 -
1768. 交替合并字符串 (Python3)
Problem: 1768. 交替合并字符串文章目录思路解题方法Code思路和21. 合并两个有序链表在思路上具有一定的相似性;学会创建dummy变量方便合并。解题方法创建dummy变量作为合并的基础;在循环中利用合适的字符串操作方法交替合并;实现两种方法,区别在于循环语句条件:一种选择在某个字符串迭代结束后变停止循环,将另一字符串的剩余内容直接合并;一种选择在循环中实现所有字符的合并。Codeclass Solution: def mergeAlternately(原创 2024-01-24 21:13:00 · 597 阅读 · 1 评论 -
21. 合并两个有序链表 (Python3)
参考:原创 2024-01-24 01:15:46 · 645 阅读 · 1 评论 -
141. 环形链表 (Python3)
第一次自己写出来,开心,总体还是非常直观的思路;在遍历中将读写麻烦的链表复制进入散列表;在遍历中判断当前访问节点是否已经访问过。参考:一文搞定常见的链表问题 (欢迎交流)一个视频讲透快慢指针:环形链表II【基础算法精讲 07】环形链表的判断环形链表以set数据结构作为散列表,存储访问过的节点;循环遍历链表,记录访问过的节点;在循环中判断当前节点是否已记录在散列表中,如果有,则为环状链表。一快一慢两个指针,慢指针一次走1,快指针一次走2;以相对速度考虑,如果有环,则一定会相遇;注意循环条件,判断条件的设计。原创 2024-01-23 13:05:58 · 386 阅读 · 1 评论 -
142. 环形链表 II(Python3)
链表本身读写困难,因此通过遍历先存入散列表;在循环中判断是否有环,并返回环的入口节点。参考:反转链表【基础算法精讲 06】环形链表 II(双指针,清晰图解)有一定技巧的数学思考,重点关注:第一次相遇慢指针未走过一个环长;第二次相遇一定发生在环的入口处。原创 2024-01-23 20:39:50 · 608 阅读 · 1 评论 -
206.反转链表 (Python3)
参考:206. 反转链表(双指针,清晰图解)原创 2024-01-23 21:49:16 · 482 阅读 · 1 评论 -
160. 相交链表(python3)
参考:哈希表:https://leetcode.cn/problems/intersection-of-two-linked-lists/solutions/811625/xiang-jiao-lian-biao-by-leetcode-solutio-a8jn/?envType=study-plan-v2&envId=top-100-liked双指针:https://leetcode.cn/problems/intersection-of-two-linked-lists/solutions/12624/原创 2024-01-21 00:56:38 · 933 阅读 · 1 评论 -
49. 字母异位词分组 (Python3)
参考:https://leetcode.cn/problems/group-anagrams/solutions/2099578/lai-zi-bei-da-suan-fa-ke-de-leetcodeti-j-wfdh/?envType=study-plan-v2&envId=top-100-likedhttps://leetcode.cn/problems/group-anagrams/solutions/520469/zi-mu-yi-wei-ci-fen-zu-by-leetcode-solut-g原创 2024-01-19 23:47:46 · 414 阅读 · 1 评论 -
128. 最长连续序列 (Python3)
参考:https://leetcode.cn/problems/longest-consecutive-sequence/solutions/276931/zui-chang-lian-xu-xu-lie-by-leetcode-solution/?envType=study-plan-v2&envId=top-100-likedhttps://leetcode.cn/problems/longest-consecutive-sequence/solutions/2362995/javapython3cha原创 2024-01-19 22:00:49 · 1978 阅读 · 0 评论 -
1. 两数之和 (Python3)
参考:https://leetcode.cn/problems/two-sum/solutions/2326193/dong-hua-cong-liang-shu-zhi-he-zhong-wo-0yvmjhttps://leetcode.cn/problems/two-sum/solution/dong-hua-cong-liang-shu-zhi-he-zhong-wo-0yvmj/灵神:“很多涉及到「两个变量」的题目,都可以枚举其中一个变量,把它当成常量看待,从而转换成「一个变量」的问题。代码实现时,原创 2024-01-19 21:47:33 · 428 阅读 · 0 评论 -
234.回文链表 (Python3)
参考:以下内容为 GPT 对 解释:In Python, is a common way to create a reversed copy of a list. This slice notation is a powerful feature in Python for list manipulation. Let’s break it down: is your list.The inside the square brackets is the slicing operator, and it原创 2024-01-19 21:57:04 · 565 阅读 · 0 评论