-
Exclusive Time of Functions: 栈
-
Friend Circles:DFS
-
Print Binary Tree:二叉树
-
Maximal Square:DP
-
Maximal Rectangle:单调栈(Histogram变形)
-
Largest Rectangle in Histogram:单调栈
-
Island Perimeter:简单对比(map+zip的使用) or 遍历查找
-
Max Area of Island:DFS(本来想用DP,发现出不来)
-
Number of Islands:DFS
-
My Calendar II:小空间匹配
-
My Calendar I:同上
*732. My Calendar III:难,小数据量可以用线段匹配,大数据量要用LCT(但是这东西看不懂)
-
Construct String from Binary Tree:中序遍历
-
Word Ladder:BFS,需要考虑wordlist的类型,如果是list会超时,所以需要选用set
*126. Word Ladder II:待完成
-
Maximum Length of Repeated Subarray:基本匹配
-
Minimum Size Subarray Sum:注意避免TLE
-
Minimum Window Substring:因为元素个数问题,不能用set
-
Wiggle Sort II:基于中间值的三段排序,或者直接排序
-
Sort Colors:/
-
Simplify Path:split和join的使用
-
Longest Palindromic Substring:和718不同,首先需要判断回文点
-
Palindromic Substrings:题目要求低,所以O(n2)的不会TLE,还是马拉车算法学习一个
-
Shortest Palindrome:easy game
-
Longest Palindromic Subsequence:DP
*730. Count Different Palindromic Subsequences:比较难的DP,需要重新做
-
Candy:很简单的一道算法题,一开始没想明白
-
Best Time to Buy and Sell Stock II:基础贪婪
-
Best Time to Buy and Sell Stock:Kadane算法(最大子序列和)
-
Best Time to Buy and Sell Stock III:DP
-
Best Time to Buy and Sell Stock IV:DP,需要判断交易次数和价格数量的大小关系,不然会爆内存
-
Construct Binary Tree from Preorder and Inorder Traversal:递归建树
-
Construct Binary Tree from Inorder and Postorder Traversal:同上
-
Binary Search Tree Iterator:题目描述不好,就是做一个inorder遍历
-
Binary Tree Inorder Traversal:递归
-
Binary Tree Preorder Traversal:同上
-
Binary Tree Postorder Traversal:同上
-
Validate IP Address:看起来很简单,但有很多坑
-
Palindrome Partitioning II:DP
-
Palindrome Partitioning:循环+递归
-
Image Smoother:算法很简单,但是各种极端情况都需要考虑
-
Trapping Rain Water:双指针
*407. Trapping Rain Water II:BFS
-
Find K Pairs with Smallest Sums:堆
-
Kth Smallest Element in a Sorted Matrix:bisect的灵活使用
*719. Find K-th Smallest Pair Distance:和378类似,但容易TLE,难
-
Integer to English Words:注意打表的拼写
-
Integer to Roman:暴力打表
-
Roman to Integer:判断低位字母的位置,标flag
-
Symmetric Tree:递归
*207. Course Schedule:DFS
- Ransom Note:统计
*691. Stickers to Spell Word:DP,比较难
-
Two Sum:/
-
Two Sum II - Input array is sorted:双指针,按1的做法会TLE
-
Two Sum IV - Input is a BST:/
-
Insert Delete GetRandom O(1) - Duplicates allowed:构造完整的数据结构
-
Insert Delete GetRandom O(1):同上
-
Add Two Numbers:/
-
Add Two Numbers II:/
-
Construct the Rectangle:/
-
Repeated Substring Pattern:/
-
Repeated String Match:/
-
Implement strStr():/
-
Palindrome Linked List.py:/
-
Reverse Linked List:/
-
Reverse Linked List II:比上一个调起来稍难
-
Intersection of Two Linked Lists:/
*143. Reorder List:in-place,难
-
Random Pick Index:/
-
Linked List Random Node:Reservoir Sampling,水池抽样
-
Sqrt(x):/
*316. Remove Duplicate Letters:难,启发式思路
-
Valid Perfect Square:/
-
Sum of Square Numbers:/
-
Pow(x, n):/
-
Super Pow:注意TLE
-
Valid Number:trick method,还可以用re和DFA敏感字过滤
-
String to Integer (atoi):注意细节
-
Jump Game:/
-
Partition Labels:/
-
Reorganize String:/
-
Range Sum Query - Immutable:求和数组
-
Range Sum Query - Mutable:线段树(还可以用BIT)
-
Range Sum Query 2D - Immutable:求和数组强化版
-
Longest Substring Without Repeating Characters:双指针
-
Median of Two Sorted Arrays.py:/
-
Toeplitz Matrix:/
-
ZigZag Conversion:模拟
-
Valid Parenthesis String:/
-
Next Greater Element III:注意32bit数,判断上限
-
Next Greater Element I:/
-
Next Greater Element II:/
-
Valid Parentheses:/
*591. Tag Validator:RE
- Generate Parentheses:/
*32. Longest Valid Parentheses:DP
*301. Remove Invalid Parentheses:BFS
-
Move Zeroes:/
-
Remove Element:/
-
Remove Duplicates from Sorted Array:/
-
Remove Linked List Elements:/
-
Arithmetic Slices:/
-
Longest Uncommon Subsequence II:/
-
Find Median from Data Stream:heap
-
Sliding Window Median:/
-
Same Tree:/
-
Trim a Binary Search Tree:/
-
Add One Row to Tree:/
-
House Robber II:/
-
House Robber:/
-
House Robber III:/
-
Average of Levels in Binary Tree:/
-
Binary Tree Level Order Traversal:/
-
Binary Tree Level Order Traversal II:/
-
Binary Tree Maximum Path Sum:/
-
Path Sum:negative value is possible
-
Path Sum II:/
-
Path Sum III:/
-
Smallest Rotation with Highest Score:/
-
Multiply Strings:/
-
Plus One:/
-
Add Binary:/
-
Add Strings:/
-
Factorial Trailing Zeroes:/
-
Number of Digit One:/
-
Palindrome Number:/
-
Power of Three:/
-
Power of Two:/
-
Power of Four:/
-
Reach a Number:考虑如何达到最小
-
Add Digits:/
-
Set Mismatch:/
-
Count Numbers with Unique Digits:/