【leetcode笔记】Python版 刷题目录

最近的更新在github上,访问我的github仓库:https://github.com/JackKuo666/leetcode_notes

目录如下:


# Title Solution Basic idea (One line) Note Difficulty
1 两数之和 Python 1. Hash O(n) and O(n) space.
2. 暴力遍历法 O(n^2) and O(1).
3.sort+双指针 >O(n) and O(n)
没排序的输入,最好使用Hashmap法 Easy
2 两个链表数字之和 Python 1.分布遍历两个链表,转成数字,相加,然后转成链表 O(n) and O(n) Medium
3 最长无重复子字符串 Python 1.哈希表+单指针 O(n) and O(1) Medium
4 两个排序列表的中位数 Python 1.常规解法:合并两个列表+sort() O((m+n)log(m+n))
2.二分查找法 O(log(m+n))
二分查找法解析见这里 Hard
5 最长回文子串 Python 1.DP: O(n^2) and O(n^2)
2.manacher算法 O(n) and O(n)
解析请看这里 Medium
6 Z字形变换解析 Python 1.创建一个list保存,然后打印出来 O(n) and O(n) 解析见我的博客 Medium
7 反向整数 Python 1.str法 24ms
2.除法 24ms
3.str法+abs 36ms
Easy
8 字符串转整形 Python 1.判断法 O(n) and O(1) Medium
9 回文数字 Python 1.str法 76ms Easy
10 正则表达式匹配 Python 1.内置函数 64ms
2.递归 TLE
3.DP O(mn) and O(mn)
解析见我的博客 Hard
11 大多数水的容器 Python 1.双指针 O(n^2) and O(1) Medium
12 整数转罗马数 Python 1.字典法 注意:4:不是 IIII 而是 IV Medium
13 罗马数转整数 Python 1.字典法 IV:4 -> IIII IX:9 -> VIIII 就可以方便的使用字典法 Easy
14 最长的共同前缀 Python 1.zip(*strs)+set O(n) and O(1) 记得zip(*strs)用法 Easy
15 三数之和 Python 1.三指针 O(n^2) and O(1) Since sorting is done in O(nlogn),which is less than O(n^2) you can ignore it.
Of course only because the total would be the sum O(nlogn + n^2)
Medium
16 三数之和最近 Python 1.三指针 O(n^2) and O(1) Medium
17 电话号码的字母组合 Python 1.数组法 O(n4^(n+1)) and O(n)
2.回溯法 > O(n
4^(n+1)) and O(n)
Medium
18 四数之和 Python 1.递归到2sum O(n^3) and O(n) 本方法是Nsum递归到2sum的通用解法
解析见这里
Medium
19 从列表末尾删除第N个节点 Python 1.数组遍历法 O(n^2) and O(n)
2.递归法 O(n) and O(1) 推荐
3.快慢指针法 O(n^2) and O(1) 标准解法
基础解法是法1;递归法来自这里,很巧妙;标准解法是法3 Medium

之前随便刷的目录:

哈希表:1.two-sum: https://leetcode.com/problems/two-sum/description/

【leetcode笔记】Python实现6.Z字形变换

【leetcode笔记】Python实现9.回文数
【leetcode笔记】Python实现18.四数之和

【leetcode笔记】Python实现19. 删除链表的倒数第N个节点
【leetcode笔记】Python实现:31.下一个排列

二分(题号:69):https://leetcode.com/problems/sqrtx/description/

荷兰国旗问题:75. Sort Colors
https://leetcode.com/problems/sort-colors/description/

双指针:167. Two Sum II - Input array is sorted
https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/description/

排序:

快速选择、堆排序:215. Kth Largest Element in an Array
https://leetcode.com/problems/kth-largest-element-in-an-array/description/
【leetcode笔记】Python实现215.Kth Largest Element in an Array

桶排序:347. Top K Frequent Elements
https://leetcode.com/problems/top-k-frequent-elements/description/
【leetcode笔记】Python实现347. Top K Frequent Elements

贪心:455. Assign Cookies
https://leetcode.com/problems/assign-cookies/description/

分治(题号:241):https://leetcode.com/problems/different-ways-to-add-parentheses/description/

【leetcode笔记】Python实现 LeetCode 241. Different Ways to Add Parentheses
链表(题号:160):https://leetcode.com/problems/intersection-of-two-linked-lists/description/
【leetcode笔记】Python实现 LeetCode 160. Intersection of Two Linked Lists

字符串(题号:242):https://leetcode.com/problems/valid-anagram/description/
栈和队列(题号:232):https://leetcode.com/problems/implement-queue-using-stacks/description/
【leetcode笔记】Python实现 232. Implement Queue using Stacks

字符串(409):https://leetcode.com/problems/longest-palindrome/description/

数组和矩阵(378):https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/description/

位运算(260):https://leetcode.com/problems/single-number-iii/description/

位运算(136):https://leetcode.com/problems/single-number/description/

数学进制转换(504):https://leetcode.com/problems/base-7/description/

相遇问题(462):https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/description/

多数投票问题(169):https://leetcode.com/problems/majority-element/description/

树:


递归(110):https://leetcode.com/problems/balanced-binary-tree/description/


层次遍历(513):https://leetcode.com/problems/find-bottom-left-tree-value/description/


前中后序遍历(144):https://leetcode.com/problems/binary-tree-preorder-traversal/description/


BST(230):https://leetcode.com/problems/kth-smallest-element-in-a-bst/description/


Trie(208):https://leetcode.com/problems/implement-trie-prefix-tree/description/
https://blog.csdn.net/weixin_37251044/article/details/88822071

图:


二分图(785):https://leetcode.com/problems/is-graph-bipartite/description/
【leetcode笔记】Python实现 785. Is Graph Bipartite?

拓扑排序(207):https://leetcode.com/problems/course-schedule/description/
【leetcode笔记】Python实现 207. Course Schedule

并查集(684):https://leetcode.com/problems/redundant-connection/description/

搜索:

BFS(279):https://leetcode.com/problems/perfect-squares/description/
【leetcode笔记】Python实现 279. Perfect Squares

DFS(695):https://leetcode.com/problems/max-area-of-island/description/
【leetcode笔记】Python实现 695. Max Area of Island

Backtracking(17):https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/
【leetcode笔记】Python实现 17. Letter Combinations of a Phone Number

动态规划:

斐波那契数列(70):https://leetcode.com/problems/climbing-stairs/description/

矩阵路径(64):https://leetcode.com/problems/minimum-path-sum/description/
【leetcode笔记】Python实现 64. Minimum Path Sum

数组区间(303):https://leetcode.com/problems/range-sum-query-immutable/description/

分割整数(343):https://leetcode.com/problems/integer-break/description/

【leetcode笔记】Python实现 343. Integer Break

最长递增子序列(300):https://leetcode.com/problems/longest-increasing-subsequence/description/

【leetcode笔记】Python实现 300. Longest Increasing Subsequence

0-1 揹包(416):https://leetcode.com/problems/partition-equal-subset-sum/description/

【leetcode笔记】Python实现 416. Partition Equal Subset Sum

股票交易(309):https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/

【leetcode笔记】Python实现 714. Best Time to Buy and Sell Stock with Transaction Fee
【leetcode笔记】Python实现 309. Best Time to Buy and Sell Stock with Cooldown

字符串编辑(583):https://leetcode.com/problems/delete-operation-for-two-strings/description/

【leetcode笔记】Python实现 583. Delete Operation for Two Strings

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章