# Algorithm Problem Classification

An algorithm problem contains 3 parts: input, output and solution/algorithm. The input can be an array, string, matrix, tree, linked list, graph, etc. The algorithm solution can be dynamic programming, binary search, BFS, DFS, or topological sort. The solution can also be a data structure, such as a stack, queue/dequeue, hash set, tree set, hash map, tree (heap, binary search tree, trie, segment tree, binary index tree), disjoint set, etc. In this post, problems are tagged by input data structures or algorithms.

1. Array/String

--Binary Search--
Search Insert Position
Median of Two Sorted Arrays
Find Minimum in Rotated Sorted Array: I, II
Find First and Last Position of Element in Sorted Array
Guess Number Higher or Lower
Search in Rotated Array:I, II
Longest Increasing Subsequence, Count of Smaller Numbers After Self
Russian Doll Envelopes
H-Index, H-Index II

--Sum subarray related problems--
Two Sum, Maximum Size Subarray Sum Equals k, Subarray Sum Equals K

--HashSet--
Longest Consecutive Sequence

--Caching--
Majority Element: I, II
Increasing Triplet Subsequence, Find the 2nd Largest Elements in an array

--TreeSet--
Contains Duplicate: I, II, III
Max Sum of Rectangle No Larger Than K
Maximum Sum Of Subarray Close To K
K Empty Slots

--Stream--(deque/caching/heap/treeset)
Sliding Window Maximum
Moving Average from Data Stream
Find Median from Data Stream
Data Stream as Disjoint Intervals
Streaming random: Linked List Random Node, Shuffle an Array

--tracking index using an array--
Ugly Number, Ugly Number II
Super Ugly Number
Find K Pairs with Smallest Sums from two arrays

--Rotate--
Rotate Array, Reverse Words in a String

--Finding a Number--
Missing Number
Find the duplicate number
First Missing Positive

--using index to add elements to a list--
Queue Reconstruction by Height

--Iterate within a boundary if the boundary is fixed--
Binary Watch
Next Closest Time

2. Matrix

--queue--
Design Snake Game

--union-find (disjoint set)--
Number of Islands II
Number of Connected Components in an Undirected Graph
Most Stones Removed with Same Row or Column

--BFS--
Surrounded Regions (BFS)

--matrix multiplication--
Sparse Matrix Multiplication

4. Tree

--traveral--
Binary Tree Traversal: Preorder, Inorder, Postorder, Level Order, Level Order II, Vertical Order

--Segment Tree & Binary Index Tree--
Range Sum Query - Mutable
The Skyline Problem

5. Stack

--Stack and Queue data structure implementation (get familiar with stack and queue)--
Implement Stack using Queues
Implement Queue using Stacks
Implement a Stack Using an Array
Implement a Queue using an Array

--Stack--Largest Rectangle--
Largest Rectangle in Histogram
Maximal Rectangle

6. DFS

7. Dynamic Programming

8. Data Structure Design

9. Bit Manipulation

10. Graph

----topological sort----
Course Schedule
Course Schedule II
Minimum Height Trees

----BFS/DFS----
Graph Valid Tree
Clone Graph
Reconstruct Itinerary

11. Math/Numbers

Category >> Algorithms
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
```<pre><code>
String foo = "bar";
</code></pre>
```