leetcode是一个很有名的在线OJ,今年新增了Database和shell模块,难度分为easy、medium和hard三档,非常适合新手练习数据结构和算法,支持多种语言,但是目前只支持英文刷题。
已经在leetcode上断断续续刷了一年题了,但是之前一直没有把解题思路记录下来,很多题已经忘记了,再次遇到同类型的题又不知道从何下手,现更新此博客,记录下刷题的思路,加深了对知识点的理解。编程语言使用Swift。
首先声明,我也只是个算法菜鸟,为加强算法能力在leetcode上刷题,如果解题思路有问题,或对算法有可优化的地方,才疏学浅,欢迎指出。 在此附上github 传送门,仓库内有之前的刷题记录,均已通过leetcode校验,由于时间比较长,leetcode上可能会有所调整,有任何问题,欢迎反馈。
Stack
84. Largest Rectangle in Histogram
199. Binary Tree Right Side View
Greedy
738. Monotone Increasing Digits
659. Split Array into Consecutive Subsequences
BFS
DFS
114. Flatten Binary Tree to Linked List
98. Validate Binary Search Tree
797. All Paths From Source to Target
String
5. Longest Palindromic Substring
821. Shortest Distance to a Character
Tree
653. Two Sum IV - Input is a BST
669. Trim a Binary Search Tree
637. Average of Levels in Binary Tree
671. Second Minimum Node In a Binary Tree
606. Construct String from Binary Tree
Binary Tree Traversal(preoder、inorder、level、zigzal level)
662. Maximum Width of Binary Tree
230. Kth Smallest Element in a BST
783. Minimum Distance Between BST Nodes
DP
Unique Binary Search Trees I, II
718. Maximum Length of Repeated Subarray
583. Delete Operation for Two Strings
698. Partition to K Equal Sum Subsets
823. Binary Trees With Factors
Hash Table
Array
747. Largest Number At Least Twice of Others
795. Number of Subarrays with Bounded Maximum
807. Max Increase to Keep City Skyline
825. Friends Of Appropriate Ages
826. Most Profit Assigning Work
String
522. Longest Uncommon Subsequence II
424. Longest Repeating Character Replacement
830. Positions of Large Groups
831. Masking Personal Information
820. Short Encoding of Words 824. Goat Latin 833. Find And Replace in String
List
725 Split Linked List in Parts
Bit Manipulation
Math
592. Fraction Addition and Subtraction