Skip to content

Garacc/LeetCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Summary

  1. Exclusive Time of Functions: 栈

  2. Friend Circles:DFS

  3. Print Binary Tree:二叉树

  4. Maximal Square:DP

  5. Maximal Rectangle:单调栈(Histogram变形)

  6. Largest Rectangle in Histogram:单调栈

  7. Island Perimeter:简单对比(map+zip的使用) or 遍历查找

  8. Max Area of Island:DFS(本来想用DP,发现出不来)

  9. Number of Islands:DFS

  10. My Calendar II:小空间匹配

  11. My Calendar I:同上

*732. My Calendar III:难,小数据量可以用线段匹配,大数据量要用LCT(但是这东西看不懂)

  1. Construct String from Binary Tree:中序遍历

  2. Word Ladder:BFS,需要考虑wordlist的类型,如果是list会超时,所以需要选用set

*126. Word Ladder II:待完成

  1. Maximum Length of Repeated Subarray:基本匹配

  2. Minimum Size Subarray Sum:注意避免TLE

  3. Minimum Window Substring:因为元素个数问题,不能用set

  4. Wiggle Sort II:基于中间值的三段排序,或者直接排序

  5. Sort Colors:/

  6. Simplify Path:split和join的使用

  7. Longest Palindromic Substring:和718不同,首先需要判断回文点

  8. Palindromic Substrings:题目要求低,所以O(n2)的不会TLE,还是马拉车算法学习一个

  9. Shortest Palindrome:easy game

  10. Longest Palindromic Subsequence:DP

*730. Count Different Palindromic Subsequences:比较难的DP,需要重新做

  1. Candy:很简单的一道算法题,一开始没想明白

  2. Best Time to Buy and Sell Stock II:基础贪婪

  3. Best Time to Buy and Sell Stock:Kadane算法(最大子序列和)

  4. Best Time to Buy and Sell Stock III:DP

  5. Best Time to Buy and Sell Stock IV:DP,需要判断交易次数和价格数量的大小关系,不然会爆内存

  6. Construct Binary Tree from Preorder and Inorder Traversal:递归建树

  7. Construct Binary Tree from Inorder and Postorder Traversal:同上

  8. Binary Search Tree Iterator:题目描述不好,就是做一个inorder遍历

  9. Binary Tree Inorder Traversal:递归

  10. Binary Tree Preorder Traversal:同上

  11. Binary Tree Postorder Traversal:同上

  12. Validate IP Address:看起来很简单,但有很多坑

  13. Palindrome Partitioning II:DP

  14. Palindrome Partitioning:循环+递归

  15. Image Smoother:算法很简单,但是各种极端情况都需要考虑

  16. Trapping Rain Water:双指针

*407. Trapping Rain Water II:BFS

  1. Find K Pairs with Smallest Sums:堆

  2. Kth Smallest Element in a Sorted Matrix:bisect的灵活使用

*719. Find K-th Smallest Pair Distance:和378类似,但容易TLE,难

  1. Integer to English Words:注意打表的拼写

  2. Integer to Roman:暴力打表

  3. Roman to Integer:判断低位字母的位置,标flag

  4. Symmetric Tree:递归

*207. Course Schedule:DFS

  1. Ransom Note:统计

*691. Stickers to Spell Word:DP,比较难

  1. Two Sum:/

  2. Two Sum II - Input array is sorted:双指针,按1的做法会TLE

  3. Two Sum IV - Input is a BST:/

  4. Insert Delete GetRandom O(1) - Duplicates allowed:构造完整的数据结构

  5. Insert Delete GetRandom O(1):同上

  6. Add Two Numbers:/

  7. Add Two Numbers II:/

  8. Construct the Rectangle:/

  9. Repeated Substring Pattern:/

  10. Repeated String Match:/

  11. Implement strStr():/

  12. Palindrome Linked List.py:/

  13. Reverse Linked List:/

  14. Reverse Linked List II:比上一个调起来稍难

  15. Intersection of Two Linked Lists:/

*143. Reorder List:in-place,难

  1. Random Pick Index:/

  2. Linked List Random Node:Reservoir Sampling,水池抽样

  3. Sqrt(x):/

*316. Remove Duplicate Letters:难,启发式思路

  1. Valid Perfect Square:/

  2. Sum of Square Numbers:/

  3. Pow(x, n):/

  4. Super Pow:注意TLE

  5. Valid Number:trick method,还可以用re和DFA敏感字过滤

  6. String to Integer (atoi):注意细节

  7. Jump Game:/

  8. Partition Labels:/

  9. Reorganize String:/

  10. Range Sum Query - Immutable:求和数组

  11. Range Sum Query - Mutable:线段树(还可以用BIT)

  12. Range Sum Query 2D - Immutable:求和数组强化版

  13. Longest Substring Without Repeating Characters:双指针

  14. Median of Two Sorted Arrays.py:/

  15. Toeplitz Matrix:/

  16. ZigZag Conversion:模拟

  17. Valid Parenthesis String:/

  18. Next Greater Element III:注意32bit数,判断上限

  19. Next Greater Element I:/

  20. Next Greater Element II:/

  21. Valid Parentheses:/

*591. Tag Validator:RE

  1. Generate Parentheses:/

*32. Longest Valid Parentheses:DP

*301. Remove Invalid Parentheses:BFS

  1. Move Zeroes:/

  2. Remove Element:/

  3. Remove Duplicates from Sorted Array:/

  4. Remove Linked List Elements:/

  5. Arithmetic Slices:/

  6. Longest Uncommon Subsequence II:/

  7. Find Median from Data Stream:heap

  8. Sliding Window Median:/

  9. Same Tree:/

  10. Trim a Binary Search Tree:/

  11. Add One Row to Tree:/

  12. House Robber II:/

  13. House Robber:/

  14. House Robber III:/

  15. Average of Levels in Binary Tree:/

  16. Binary Tree Level Order Traversal:/

  17. Binary Tree Level Order Traversal II:/

  18. Binary Tree Maximum Path Sum:/

  19. Path Sum:negative value is possible

  20. Path Sum II:/

  21. Path Sum III:/

  22. Smallest Rotation with Highest Score:/

  23. Multiply Strings:/

  24. Plus One:/

  25. Add Binary:/

  26. Add Strings:/

  27. Factorial Trailing Zeroes:/

  28. Number of Digit One:/

  29. Palindrome Number:/

  30. Power of Three:/

  31. Power of Two:/

  32. Power of Four:/

  33. Reach a Number:考虑如何达到最小

  34. Add Digits:/

  35. Set Mismatch:/

  36. Count Numbers with Unique Digits:/

About

solution for leetcode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages