leetcode(持續更新......)

FFIB發表於2017-12-20

leetcode是一個很有名的線上OJ,今年新增了Database和shell模組,難度分為easy、medium和hard三檔,非常適合新手練習資料結構和演算法,支援多種語言,但是目前只支援英文刷題。

已經在leetcode上斷斷續續刷了一年題了,但是之前一直沒有把解題思路記錄下來,很多題已經忘記了,再次遇到同型別的題又不知道從何下手,現更新此部落格,記錄下刷題的思路,加深了對知識點的理解。程式語言使用Swift。

首先宣告,我也只是個演算法菜鳥,為加強演算法能力在leetcode上刷題,如果解題思路有問題,或對演算法有可優化的地方,才疏學淺,歡迎指出。 在此附上github 傳送門,倉庫內有之前的刷題記錄,均已通過leetcode校驗,由於時間比較長,leetcode上可能會有所調整,有任何問題,歡迎反饋。

Stack

739. Daily Temperatures

84. Largest Rectangle in Histogram

385. Mini Parser

199. Binary Tree Right Side View

Greedy

738. Monotone Increasing Digits

659. Split Array into Consecutive Subsequences

649. Dota2 Senate

BFS

130. Surrounded Regions

752. Open the Lock

DFS

733. Flood Fill

337. House Robber III

129. Sum Root to Leaf Numbers

114. Flatten Binary Tree to Linked List

98. Validate Binary Search Tree

547 Friend Circles

638. Shopping Offers

797. All Paths From Source to Target

String

5. Longest Palindromic Substring

804. Unique Morse Code Words

821. Shortest Distance to a Character

819. Most Common Word

Tree

654. Maximum Binary Tree

653. Two Sum IV - Input is a BST

669. Trim a Binary Search Tree

637. Average of Levels in Binary Tree

687. Longest Univalue Path

671. Second Minimum Node In a Binary Tree

606. Construct String from Binary Tree

450. Delete Node in a BST

Binary Tree Traversal(preoder、inorder、level、zigzal level)

Construct Binary Tree

662. Maximum Width of Binary Tree

623. Add One Row to Tree

652. Find Duplicate Subtrees

655. Print Binary Tree

230. Kth Smallest Element in a BST

783. Minimum Distance Between BST Nodes

814. Binary Tree Pruning

DP

740. Delete and Earn

House Robber I, II

Unique Binary Search Trees I, II

718. Maximum Length of Repeated Subarray

746. Min Cost Climbing Stairs

583. Delete Operation for Two Strings

698. Partition to K Equal Sum Subsets

486. Predict the Winner

823. Binary Trees With Factors

Hash Table

748. Shortest Completing Word

771. Jewels and Stones

781. Rabbits in Forest

811. Subdomain Visit Count

Array

747. Largest Number At Least Twice of Others

Max Chunks To Make Sorted

766. Toeplitz Matrix

795. Number of Subarrays with Bounded Maximum

807. Max Increase to Keep City Skyline

825. Friends Of Appropriate Ages

826. Most Profit Assigning Work

822. Card Flipping Game

832. Flipping an Image

String

556. Next Greater Element III

522. Longest Uncommon Subsequence II

809. Expressive Words

791. Custom Sort String

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

817. Linked List Components

Bit Manipulation

Hamming Distance

Math

592. Fraction Addition and Subtraction

754. Reach a Number

43. Multiply Strings

525. Contiguous Array

Ugly Number

812. Largest Triangle Area

789. Escape The Ghosts

829. Consecutive Numbers Sum

Binary Search

658. Find K Closest Elements

744. Find Smallest Letter Greater Than Target

相關文章