A curated collection of coding interview problems, data structure and algorithm patterns, hints, reasoning frameworks and solution approaches.
This repository is maintained by RivoHire, an AI-powered interview preparation and hiring platform.
Many candidates memorize coding solutions without learning how to identify the correct approach.
This repository focuses on the complete interview-thinking process:
- Understand the problem
- Extract important signals
- Translate signals into properties
- Identify possible patterns
- Compare alternative approaches
- State assumptions
- Analyze time and space complexity
- Implement the solution clearly
- Explain trade-offs to the interviewer
RivoHire uses the SPARK framework to help candidates recognize coding interview patterns.
Identify important words and constraints such as:
- Sorted
- Subarray
- Substring
- Pair
- Frequency
- Minimum
- Maximum
- Shortest path
- Tree
- Graph
- Repeated choices
Translate signals into algorithmic properties:
- Ordering
- Contiguity
- Connectivity
- Frequency counting
- Monotonicity
- Repeated subproblems
- Fast lookup
- Range processing
Consider likely patterns before choosing one:
- Hash map
- Two pointers
- Sliding window
- Binary search
- Prefix sum
- BFS
- DFS
- Heap
- Backtracking
- Dynamic programming
Explain why the selected pattern matches the problem better than alternatives.
State the assumptions that make the solution valid and identify what would break the approach.
Read the full guide:
How to Recognize DSA Patterns in Coding Interviews
- Two Sum
- Maximum Subarray
- Product Except Self
- Longest Substring Without Repeating Characters
- Merge Intervals
- Rotate Array
- Frequency counting
- Duplicate detection
- Complement lookup
- Grouping and indexing
- Prefix-sum lookup
- Pair sum in sorted arrays
- Palindrome checking
- Container problems
- Partitioning
- Removing duplicates
- Longest valid substring
- Maximum or minimum window
- Fixed-size window calculations
- Frequency-constrained ranges
- Search in sorted arrays
- First and last occurrence
- Rotated sorted arrays
- Binary search on answer
- Monotonic decision problems
- Reversal
- Cycle detection
- Middle node
- Merging lists
- Pointer manipulation
- Tree traversal
- Lowest common ancestor
- Connected components
- Shortest paths
- Topological sorting
- Cycle detection
- Top K elements
- Kth largest or smallest
- Scheduling
- Streaming data
- Merging sorted sources
- Knapsack
- Coin change
- Longest common subsequence
- Grid paths
- State transitions
- Memoization and tabulation
- Permutations
- Combinations
- Subsets
- Constraint solving
- Search-space exploration
Each problem should use the following structure:
Problem title
Difficulty
Problem statement
Examples
Constraints
Signals
Properties
Candidate patterns
Recommended pattern
Reasoning
Key assumptions
Hints
Time complexity
Space complexity
Solution
Alternative approaches
Common interview mistakes
Follow-up questions