LeetCode topics — Array

Data Structure

Len Chen
5 min readFeb 4, 2020

Questions

Basic

Interval

Counter

Sort

Matrix

Solutions

Basic

Two Pointers
Sliding Window
Sliding Window
Two Pointers
Count Trendings
Two Pointers with Generator
Two Pointers
Two Pointers with Greedy
Sliding Window with Greedy
Sliding Window with Greedy
Greedy
Prune and Search
Count Elements
Count Elements
Binary Search
Reverse
Index as Hash Key
Index as Hash Key
Index as Hash Key
Index as Hash Key
Ad hoc
Kadane’s Algorithm
Rolling Sum
Sort and Three Pointers, O(MlogM + NlogN)/O(1)
HashSet, O(M + N)/O(M + N)
Sort and Three Pointers, O(MlogM + NlogN)/O(1)
HashMap, O(M + N)/O(M + N)
Sort, O(NlogN)/O(1)
Counting Sort, O(N)/O(N)
Binary Search
HashMap and Two Pointers
Two Pointers
Sort, O(NlogN)/O(1)
HashSet, O(N)/O(N)
Sliding Window
Sliding Window on Buckets
Greedy with Two Pointers
Greedy with Two Pointers
Kadane’s Algorithm
Greedy
Kadane’s Algorithm on Transactions
Dynamic Programming on Transactions
Greedy or Kadane’s Algorithm on Transactions
Greedy or Dynamic Programming on Transactions
Dynamic Programming on Transactions
Dynamic Programming on Transactions
Two Pointers
Two Pointers
Two Pointers
Sort and Kadane’s Algorithm, O(NlogN)/O(1)
HashSet, O(N)/O(N)
Detect Cycle with Two Pointers
Sort and Sweep Line
Sweep Line

Interval

Greedy
Greedy
Greedy
Sort, O(NlogN)
Sweep Line, O(N + M)
Sort
Sort, O(NlogN)/O(1)
Time Sweep, O(N + (M - m))/O(M - m)
Sort and Heap
Sort on All Points
Binary Search
Heap
Binary Search
Binary Search
Queue
Greedy
Queue

Counter

Counter, O(N)/O(N)
Sort and Two Pointer, O(sort)/O(sort)
Count occurrence of each number of all subarrays
Monodeque and Sliding Window
Deque
Quick Select Algorithm
Quick Select Algorithm
Counting Sort
Buckets
Buckets
Heap
Kadane’s Algorithm
Sign Variant of Kadane’s Algorithm
Min Variant of Kadane’s Algorithm
HashMap
sliding window
HashMap
Sliding Window
Dynamic Programming on Two Directions
Kadane’s Algorithm on Max Ending and Min Ending
Kadane’s Algorithm on Prefix and Suffix
Index as Hash Key
Two Pointers
Greedy
Counting Sort
Two Scans, O(N²)/O(1)
Binary Indexed Tree, O(NlogN)/O(N)
Binary Indexed Tree

Sort

Three Pointers
Three Way Partitioning
Two Pointers
Buckets
Binary Indexed Tree
Merge Sort
Greedy
Ad hoc
Quick Select Median and Three Way Partitioning on Virtual Indexing

Matrix

Greedy
Reverse and Transpose
Rotate Four Rectangles
Simulation
Simulation
Simulation
Simulation
Kadane’s Algorithm on Four Directions, O(mn)/O(n)
Kadane’s Algorithm on Four Directions, O(4mn)/O(1)
Simulation
Simulation
HashSet
Count Delta of Each 1s
Binary Search
Prune and Search
Backtracking
Medians of Two Coordinates
Count Streaks
BFS
Binary Search on Two Coordinates
HashSet
Backtracking
Get Block Sum by 2D Prefix Matrix
Scan Increasing Squares by 2D Prefix Matrix
Dynamic Programming on Largest Rectangle Histogram with Sort
Dynamic Programming on Two Directions

--

--

Len Chen
Len Chen

No responses yet