堆,栈,队列,哈希表

注意各个数据结构的基本原理,增删查改复杂度。

Queue 题目:

  • Leetcode 225。Implement Stack using Queues
  • Leetcode 346。Moving Average from Data Stream
  • Leetcode 281。Zigzag Iterator
  • Leetcode 1429。First Unique Number
  • Leetcode 54。Spiral Matrix
  • Leetcode 362。Design Hit Counter

Stack 题目:

  • Leetcode 155。Min Stack (follow up Leetcode 716 Max Stack)
  • Leetcode 232。Implement Queue using Stacks
  • Leetcode 150。Evaluate Reverse Polish Notation
  • Leetcode 224。Basic Calculator II (I,II,III,IV)
  • Leetcode 20。Valid Parentheses
  • Leetcode 1472。Design Browser History
  • Leetcode 1209。Remove All Adjacent Duplicates in String II
  • Leetcode 1249。Minimum Remove to Make Valid Parentheses
  • Leetcode 735。Asteroid Collision

Hashmap/ Hashset 题目:

  • Leetcode 1。Two Sum
  • Leetcode 146。LRU Cache (Python 中可以使用 OrderedDict 来代替)
  • Leetcode 128。Longest Consecutive Sequence
  • Leetcode 73。Set Matrix Zeroes
  • Leetcode 380。Insert Delete GetRandom O(1)
  • Leetcode 49。Group Anagrams
  • Leetcode 350。Intersection of Two Arrays II
  • Leetcode 299。Bulls and Cows
  • Leetcode 348 Design Tic-Tac-Toe

Heap/Priority Queue 题目:

  • Leetcode 973。K Closest Points
  • Leetcode 347。Top k Largest Elements
  • Leetcode 23。Merge K Sorted Lists
  • Leetcode 264。Ugly Number II
  • Leetcode 1086。High Five
  • Leetcode 88。Merge Sorted Arrays
  • Leetcode 692。Top K Frequent Words
  • Leetcode 378。Kth Smallest Element in a Sorted Matrix
  • Leetcode 295。Find Median from Data Stream (标准解法是双 heap,但是 SortedDict 会非常容易)
  • Leetcode 767。Reorganize String
  • Leetcode 1438。Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit (这个题用单调双端队列、TreeMap、双 heap 都可以)
  • Leetcode 895。Maximum Frequency Stack
最后更新: 2/27/2024, 6:53:03 AM