Reddit Coding Interview Questions
100 Reddit coding interview problems with full optimal solutions — 34 easy, 52 medium, 14 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Reddit interviewer values, and a FAQ section.
- #1easyfrequently asked
1. Two Sum
Given an array of integers and a target, return indices of the two numbers that add up to target. Reddit uses this as a warm-up to test if you reach for a hash map without prompting — the same reflex that powers vote-deduplication and karma-event lookups.
- #2easyfrequently asked
2. Valid Parentheses
Determine if a string of brackets is balanced. Reddit uses this to test stack intuition — the same data structure that backs their comment-tree depth tracking and markdown parser for self-post bodies.
- #3easyfrequently asked
3. Merge Two Sorted Lists
Merge two sorted linked lists into one sorted list. Reddit uses this to test pointer hygiene — the same skill needed to merge ranked feed streams (hot + new + rising) without losing or duplicating posts.
- #4easysometimes asked
4. Remove Duplicates from Sorted Array
Remove duplicates in-place from a sorted array and return the new length. Reddit uses this to test two-pointer fluency — the same pattern they use to dedupe vote events from the same user_id arriving across replicas.
- #5easysometimes asked
5. Remove Element
Remove all occurrences of a target value in-place from an array. Reddit asks this to test in-place mutation patterns used in their server-side comment-tree pruning when a moderator nukes a banned user's history.
- #6easyfrequently asked
6. Search Insert Position
Find the index where a target should be inserted in a sorted array. Reddit uses this binary-search variant to gate whether candidates can implement lower_bound correctly — critical for ranked feed insertion when a new post enters Hot.
- #7easyfrequently asked
7. Maximum Subarray
Find the contiguous subarray with the largest sum. Reddit uses this to filter for candidates who recognize Kadane's algorithm — the same running-sum idea that powers their hot-score windowed-vote calculation.
- #8easysometimes asked
8. Plus One
Add one to a big integer represented as an array of digits. Reddit asks this to test careful carry-handling — the same kind of mental model needed for monotonic karma counters that survive past 2^31.
- #9easyfrequently asked
9. Merge Sorted Array
Merge two sorted arrays into the first one in-place. Reddit uses this to test back-pointer technique — the same insight powering their in-place merging of ranked feed segments without allocating a new array per request.
- #10easyfrequently asked
10. Binary Tree Inorder Traversal
Return the inorder traversal of a binary tree. Reddit asks this to test recursive vs. iterative fluency — the same primitive used to flatten their nested comment trees into linear render lists.
- #11easysometimes asked
11. Same Tree
Given two binary trees, determine if they are structurally identical with the same values. Reddit uses this to test recursion fundamentals — the basis for comparing two snapshots of a comment subtree during edit-diff display.
- #12easysometimes asked
12. Symmetric Tree
Determine if a binary tree is a mirror image of itself. Reddit asks this to gauge whether candidates can write paired-pointer recursion — the same skill needed when comparing two views of a comment tree (live vs. cached).
- #13easyfrequently asked
13. Maximum Depth of Binary Tree
Compute the depth of a binary tree. Reddit asks this to gauge basic recursion — the same primitive used to measure how deeply a comment tree can nest before they collapse it with 'continue this thread →' links.
- #14easysometimes asked
14. Balanced Binary Tree
Determine if a binary tree is height-balanced. Reddit uses this to test bottom-up recursion — the same insight that lets them detect comment subtrees that have grown pathologically deep on one side (a fingerprint of bot reply chains).
- #15easysometimes asked
15. Minimum Depth of Binary Tree
Find the minimum depth (root to nearest leaf). Reddit asks this for two-fold reason: it tests careful recursion (one-sided subtrees are a trap) and connects to early-termination patterns in their comment-tree renderer.
- #16easyrarely asked
16. Pascal's Triangle
Generate the first numRows of Pascal's Triangle. Reddit asks this to gauge basic 2D-array fluency — the same iteration pattern they use to build precomputed lookup tables for vote-decay coefficients.
- #17easyfrequently asked
17. Best Time to Buy and Sell Stock
Find the max profit from one buy + one sell of a stock-price array. Reddit uses this as a streaming-window template — the same single-pass shape used to find the best upvote burst within a post's lifetime.
- #18easysometimes asked
18. Valid Palindrome
Determine if a string is a palindrome after removing non-alphanumeric characters and lowercasing. Reddit uses this to test two-pointer technique on dirty input — exactly the kind of normalization their username/subreddit-name validation must handle.
- #19easysometimes asked
19. Single Number
Find the single non-duplicated number in an array where every other number appears twice. Reddit asks this to test bitwise reflexes — the same XOR trick used in their vote-toggle audit (each user vote should appear paired with its undo, except for the active one).
- #20easyfrequently asked
20. Linked List Cycle
Detect whether a linked list has a cycle. Reddit uses Floyd's cycle detection (tortoise and hare) to test pointer fluency — the same algorithm used in their comment-graph integrity checker to detect malformed reply cycles.
- #21easyfrequently asked
21. Min Stack
Design a stack that supports push, pop, top, and getMin in O(1). Reddit uses this to test data-structure design — the same auxiliary-state pattern they use to maintain hottest-comment-so-far while streaming an active comment thread.
- #22easysometimes asked
22. Two Sum II - Input Array Is Sorted
Find two numbers in a sorted array that sum to a target. Reddit uses this two-pointer variant to test whether candidates recognize when sorting buys them O(1) extra space — relevant for sorted vote-tally pairing.
- #23easyfrequently asked
23. Majority Element
Find the element that appears more than n/2 times in an array. Reddit uses Boyer-Moore voting to test whether candidates recognize specialized algorithms — the same vote-majority pattern matters for their vote-fraud detection (one IP shouldn't dominate a thread).
- #24easysometimes asked
24. Rotate Array
Rotate an array to the right by k steps. Reddit uses the reverse-then-reverse trick to gauge in-place manipulation — the same skill needed to rotate a fixed-size sliding ranking window without re-allocating.
- #25easyrarely asked
25. Reverse Bits
Reverse the bits of a 32-bit unsigned integer. Reddit uses this to test bitwise fluency — the same low-level operation used in their fingerprint-hash byte-swapping (some browsers send hashes in opposite endianness).
- #26easyrarely asked
26. Number of 1 Bits
Count the set bits in a 32-bit integer. Reddit uses this Hamming-weight question to test bitwise tricks — the same primitive used in their feature-flag rollout system where flag-sets are stored as bitmasks.
- #27mediumsometimes asked
27. House Robber
Maximize sum from non-adjacent array elements. Reddit asks this to test DP intuition — the same pattern used in their abuse system to select non-adjacent (non-similar) accounts when applying rate-limiting waves.
- #28easyrarely asked
28. Happy Number
Determine if a number reaches 1 under iterated sum-of-squares of digits. Reddit uses this to test cycle detection on derived sequences — the same shape as detecting fingerprint hashes that loop in their bot-detection telemetry.
- #29easyrarely asked
29. Isomorphic Strings
Check if two strings are isomorphic (each character in s can be replaced to get t). Reddit asks this to test bidirectional mapping — the same skill needed for their username-to-ID isomorphism guarantees in cross-shard joins.
- #30easyfrequently asked
30. Reverse Linked List
Reverse a singly linked list. Reddit asks this to gauge pointer fluency — the most-asked easy LL problem. The skill maps directly to reversing chronological vote-event chains during fraud investigation.
- #31mediumfrequently asked
31. Add Two Numbers
Add two big integers represented as linked lists (least-significant-digit first). Reddit asks this to test linked-list arithmetic with carry — the same kind of pointer-walking they use to merge cross-shard counter chunks.
- #32mediumfrequently asked
32. Longest Substring Without Repeating Characters
Find the longest substring without repeating characters. Reddit asks this to test sliding-window technique — the same pattern used to find the longest run of non-duplicate IPs hitting an endpoint (a fraud-detection primitive).
- #33mediumsometimes asked
33. Longest Palindromic Substring
Find the longest palindromic substring of a string. Reddit asks this to test expand-around-centers — the same pattern used in their similarity-detection between post titles (mirror-image substring matching for spam detection).
- #34mediumfrequently asked
34. Container With Most Water
Given heights, find the two lines that form the container holding the most water. Reddit uses this two-pointer problem to test greedy/monotone intuition — analogous to choosing the two endpoints of a time-window to maximize comment volume.
- #35mediumfrequently asked
35. 3Sum
Find all unique triplets that sum to zero. Reddit uses this to test sort + two-pointer + dedup — the same triple-key correlation used in their abuse-detection to find triple-coincidence patterns (IP + user-agent + timing).
- #36mediumsometimes asked
36. Letter Combinations of a Phone Number
Generate all letter combinations from a phone-keypad number string. Reddit uses this backtracking problem to test recursive enumeration — the same shape they'd use to enumerate all tag-permutations for ad targeting.
- #37mediumfrequently asked
37. Remove Nth Node From End of List
Remove the Nth-from-end node in a single pass. Reddit asks this to test the two-pointer-with-gap technique — the same windowed-walk used in their rate-limiter to expire the Nth-most-recent event.
- #38mediumsometimes asked
38. Generate Parentheses
Generate all combinations of n pairs of well-formed parentheses. Reddit uses this backtracking problem to test pruning skills — the same shape they'd use to enumerate valid markdown nesting structures during comment rendering.
- #39mediumsometimes asked
39. Swap Nodes in Pairs
Swap every two adjacent nodes in a linked list. Reddit asks this to test multi-pointer manipulation — the same pattern needed when re-ordering pairs of items in their ranked feed during an A/B test.
- #40mediumrarely asked
40. Next Permutation
Compute the lexicographically next permutation in-place. Reddit asks this rare problem to test in-place manipulation under a non-obvious algorithm — connects to enumerating moderator action sequences in their audit trail.
- #41mediumfrequently asked
41. Search in Rotated Sorted Array
Search for a target in a rotated sorted array in O(log n). Reddit asks this to test binary-search variants — the same skill used when their pagination cursor wraps around a sorted vote-timestamp index.
- #42mediumsometimes asked
42. Find First and Last Position of Element in Sorted Array
Find the first and last index of a target in a sorted array. Reddit asks this to test bound-based binary search — the same shape used when querying their time-bucketed vote logs for the range of events matching a timestamp.
- #43mediumrarely asked
43. Valid Sudoku
Determine if a 9x9 Sudoku board configuration is valid. Reddit uses this to test multi-key hash-set technique — the same shape used when validating that a moderator action is consistent across multiple constraint sets (subreddit + user + action).
- #44mediumsometimes asked
44. Combination Sum
Find all unique combinations of candidates that sum to target (with repetition). Reddit uses this to test backtracking — the same pattern they'd use to enumerate sets of moderation actions that combine to a desired outcome.
- #45mediumrarely asked
45. Combination Sum II
Find all unique combinations where each candidate is used at most once. Reddit uses this variant to test dedup with duplicates — the same skill needed when uniquifying overlapping abuse signals (each user-IP fingerprint appears at most once per detection batch).
- #46mediumrarely asked
46. Multiply Strings
Multiply two big integers represented as strings. Reddit asks this to test grade-school multiplication translated to code — the same shape used in their cross-shard counter merging where each shard returns a digit-encoded partial sum.
- #47mediumsometimes asked
47. Permutations
Generate all permutations of distinct integers. Reddit uses this to test backtracking — the same pattern they'd use to enumerate orderings of A/B test variants for users.
- #48mediumsometimes asked
48. Rotate Image
Rotate an n x n matrix 90 degrees clockwise in-place. Reddit asks this to test the transpose-then-reverse trick — the same building block they use when re-orienting heatmap matrices for moderator dashboards.
- #49mediumfrequently asked
49. Group Anagrams
Group strings that are anagrams of each other. Reddit uses this to test hash-key design — the same shape used when clustering near-duplicate post titles for spam detection (sort the letters to get a normalized fingerprint).
- #50mediumsometimes asked
50. Spiral Matrix
Traverse a matrix in spiral order. Reddit uses this to test boundary tracking — the same skill needed when iterating around 2D region tiles in their image-grid rendering for AR/AR filters.
- #51mediumsometimes asked
51. Jump Game
Determine if you can reach the last index of an array starting from index 0. Reddit asks this to test greedy intuition — the same forward-reachability check used in their dependency-resolution for ad-pixel firing order.
- #52mediumfrequently asked
52. Merge Intervals
Merge overlapping intervals. Reddit uses this canonical interval problem to test sort + scan — the same shape used when merging consecutive vote-window aggregations into a single hot-score period.
- #53mediumsometimes asked
53. Unique Paths
Count the number of paths from top-left to bottom-right of an m x n grid (right/down only). Reddit uses this DP problem as a clean grid-DP warm-up before harder routing problems.
- #54mediumsometimes asked
54. Minimum Path Sum
Find the path from top-left to bottom-right with minimum sum (right/down only). Reddit uses this to extend grid DP with weights — the same routing pattern they'd use to minimize CDN-cost for inter-region replication.
- #55mediumsometimes asked
55. Simplify Path
Simplify a Unix-style absolute file path. Reddit uses this string + stack problem to test parsing — the same pattern they apply when canonicalizing /r/sub/comments/abc/comment/xyz URLs for cache keying.
- #56mediumsometimes asked
56. Set Matrix Zeroes
If an element in an m x n matrix is 0, zero out its entire row and column. Reddit uses this to test in-place 2D manipulation under a tight memory budget — the same shape they'd use to scrub rows/columns of an analytics matrix when a user is GDPR-deleted.
- #57mediumsometimes asked
57. Search a 2D Matrix
Search a sorted 2D matrix where each row is sorted and each row's first > previous row's last. Reddit uses this to test the 1D-binary-search-on-flattened-matrix trick.
- #58mediumsometimes asked
58. Sort Colors
Sort an array containing only 0s, 1s, and 2s in-place (Dutch national flag). Reddit uses this to test the three-pointer partition — the same shape used when bucketing items into three priority lanes in their ranking pipeline.
- #59mediumrarely asked
59. Combinations
Generate all combinations of k numbers from 1 to n. Reddit uses this to test backtracking with start-index — the same enumeration shape they'd use when picking k subreddits for an admin notification A/B test.
- #60mediumfrequently asked
60. Subsets
Generate all 2^n subsets of a set of distinct integers. Reddit uses this to test backtracking and bitmask enumeration — the same enumeration used when computing all flag-combination buckets for feature-rollout cohorts.
- #61mediumsometimes asked
61. Word Search
Check if a word exists in a 2D character grid (adjacent cells, no reuse). Reddit uses this to test DFS with backtracking on grids — the same shape used in their image-grid content-moderation when scanning for embedded text patterns.
- #62mediumrarely asked
62. Remove Duplicates from Sorted Array II
Allow at most two occurrences of each value in a sorted array, in-place. Reddit uses this to test slow/fast pointer with a count threshold — the same shape as rate-limiting to N per user in their abuse pipeline.
- #63mediumsometimes asked
63. Decode Ways
Count the number of ways to decode a digit string to letters (A=1..Z=26). Reddit uses this DP problem to test recurrence design — the same shape used in their tokenizer when a sequence of input bytes has multiple valid prefix interpretations.
- #64mediumfrequently asked
64. Binary Tree Level Order Traversal
Return level-order traversal of a binary tree as a list of lists. Reddit uses this BFS warm-up to test queue technique — the same shape used in their comment-tree renderer which paginates by depth level.
- #65mediumsometimes asked
65. Binary Tree Zigzag Level Order Traversal
Return zigzag level-order traversal of a binary tree. Reddit asks this as a BFS variation to test deque vs. queue intuition — relevant for their alternating-direction rendering pattern in certain UI experiments.
- #66mediumsometimes asked
66. Construct Binary Tree from Preorder and Inorder Traversal
Rebuild a binary tree from preorder and inorder traversals. Reddit uses this to test tree-recursion with index management — the same skill used in their comment-tree audit where they must reconstruct the original tree from serialized snapshots.
- #67mediumfrequently asked
67. Validate Binary Search Tree
Determine whether a binary tree is a valid BST. Reddit uses this to test the bounded-recursion pattern — the same shape used when validating that a comment-tree's parent timestamps satisfy a strict-monotonic constraint.
- #68mediumfrequently asked
68. Word Break
Determine if a string can be segmented into words from a dictionary. Reddit uses this DP problem to test the prefix-suffix decomposition pattern — the same shape used when tokenizing usernames into recognized subreddit references during mention detection.
- #69mediumfrequently asked
69. LRU Cache
Design an LRU cache with O(1) get and put. Reddit uses this to test data-structure composition (hash + doubly-linked-list) — the same primitive used in their hot-post cache eviction layer in front of Postgres.
- #70mediumfrequently asked
70. Number of Islands
Count the number of connected components of 1s in a grid. Reddit uses this DFS/BFS classic to test grid traversal — the same shape used when clustering coordinated abuse cells in their fraud-detection IP-grid.
- #71mediumfrequently asked
71. Course Schedule
Determine if you can finish all courses given prerequisite pairs (cycle detection in a DAG). Reddit uses this to test topological-sort intuition — the same shape used when validating cross-shard data-migration dependency graphs.
- #72mediumsometimes asked
72. Course Schedule II
Return any valid course order given prerequisites. Reddit uses this topo-sort problem to validate dependency-graph linearization — the same shape used when scheduling a chain of database migrations.
- #73mediumfrequently asked
73. Implement Trie (Prefix Tree)
Implement a trie supporting insert, search, and startsWith. Reddit uses this to test prefix-tree design — the same data structure they use in their autocomplete service for subreddit and username completion.
- #74mediumfrequently asked
74. Kth Largest Element in an Array
Find the kth-largest element. Reddit uses this to test heap and quickselect — the same primitive that powers their top-k post selector for ranking feed pages.
- #75easysometimes asked
75. Contains Duplicate
Determine if an array contains duplicate values. Reddit uses this as a hash-set warm-up — the same primitive used to detect duplicate vote events arriving from sharded gateways.
- #76easysometimes asked
76. Contains Duplicate II
Determine if duplicate values exist within k indices apart. Reddit uses this to test sliding-window with hash — the same shape used in their abuse pipeline to detect repeated votes from the same user_id within a short time window.
- #77easysometimes asked
77. Invert Binary Tree
Invert a binary tree (mirror left and right at every node). Reddit asks this canonical question — connects to alternating-view rendering in their right-side-vs-left-side AB tests.
- #78mediumsometimes asked
78. Kth Smallest Element in a BST
Find the kth smallest in a BST. Reddit uses this to test inorder + early termination — relevant for ranked-paginated retrieval from an in-memory BST of upvote scores.
- #79mediumfrequently asked
79. Lowest Common Ancestor of a Binary Tree
Find the lowest common ancestor of two nodes in a binary tree. Reddit uses this canonical LCA problem to test post-order recursion — the same shape they use to find the nearest common parent comment when merging conflicting moderator threads.
- #80mediumfrequently asked
80. Product of Array Except Self
Return an array where each element is the product of all others (no division). Reddit uses this to test prefix/suffix product technique — the same shape used in their cross-shard counter reconciliation where you compute totals excluding one shard.
- #81mediumfrequently asked
81. Top K Frequent Elements
Return the k most frequent elements in an array. Reddit uses this to test count + heap design — the exact shape of their trending-words detector in subreddit titles over a time window.
- #82mediumsometimes asked
82. Coin Change
Find the minimum number of coins to make a target amount. Reddit uses this DP problem to test classic unbounded-knapsack — the same shape used when computing minimum SQL queries to satisfy a multi-resource quota.
- #83easyrarely asked
83. Intersection of Two Arrays
Return the intersection of two arrays as unique values. Reddit uses this hash-set warm-up to test set operations — the same primitive used to find overlapping users between two subreddits for cross-promotion.
- #84easysometimes asked
84. Move Zeroes
Move zeros to the end while keeping the order of non-zeros. Reddit uses this to test in-place two-pointer technique — the same compact-and-tombstone pattern used when removing soft-deleted comments from a tree without rebuilding it.
- #85mediumsometimes asked
85. Longest Increasing Subsequence
Find the length of the longest strictly increasing subsequence. Reddit uses this to test DP + binary search — relevant when finding the longest monotonically increasing run in a vote stream (a bot-detection signal).
- #86mediumsometimes asked
86. Reverse Words in a String
Reverse the order of words in a string. Reddit uses this string-manipulation question to test pointer fluency — the same shape used when normalizing search query terms in their suggest service.
- #87hardsometimes asked
87. Word Ladder
Find the shortest transformation sequence from beginWord to endWord (one-letter change per step). Reddit uses this BFS problem to test graph exploration — the same shortest-path shape used when tracing comment-edit chains across moderator interventions.
- #88hardrarely asked
88. Median of Two Sorted Arrays
Find the median of two sorted arrays in O(log(min(m, n))). Reddit uses this to test binary-search-over-partitions — relevant when merging sorted vote-tally arrays from two shards to find a percentile cutoff.
- #89hardfrequently asked
89. Merge k Sorted Lists
Merge k sorted linked lists into one sorted list. Reddit uses this to test heap-based merging — the exact shape used when merging hot/new/rising/controversial ranked streams into a single user feed.
- #90hardrarely asked
90. Regular Expression Matching
Implement regex matching for '.' and '*'. Reddit uses this DP problem to test state-machine thinking — the same shape used when implementing custom rule-based content filters in their AutoModerator engine.
- #91hardsometimes asked
91. Reverse Nodes in k-Group
Reverse nodes of a linked list in k-groups. Reddit uses this to test linked-list manipulation under partial-reverse rules — relevant when re-ordering feed chunks in their ranked-page generation.
- #92hardrarely asked
92. Longest Valid Parentheses
Find the length of the longest valid parentheses substring. Reddit uses this stack-based DP problem to test sophisticated index tracking — the same shape used when validating longest valid markdown nesting in user input.
- #93hardrarely asked
93. Sudoku Solver
Solve a 9x9 Sudoku puzzle in-place using backtracking. Reddit uses this to test constraint-propagation backtracking — the same shape used when assigning thousands of users to a finite set of moderator-approval slots under multiple non-conflict constraints.
- #94hardrarely asked
94. First Missing Positive
Find the smallest missing positive integer in O(n) time and O(1) space. Reddit uses this for the cyclic-sort trick — clever in-place manipulation relevant to compact range-checks during shard-key allocation.
- #95hardfrequently asked
95. Trapping Rain Water
Compute how much rain water is trapped between elevation bars. Reddit uses this to test two-pointer + min/max tracking — the same shape used to identify dips between vote-volume peaks in their popularity-decay analysis.
- #96hardrarely asked
96. Wildcard Matching
Match a string against a pattern with '?' and '*'. Reddit uses this DP problem to test pattern-matching state — the same shape used in their AutoModerator regex-lite engine for subreddit-specific rules.
- #97hardrarely asked
97. N-Queens
Place n queens on an n×n board so none attack each other. Reddit uses this backtracking classic to test constraint-encoded DFS — the same shape they use when scheduling non-conflicting moderator-action sequences across overlapping subreddits.
- #98hardsometimes asked
98. Largest Rectangle in Histogram
Find the largest rectangle in a histogram. Reddit uses this monotonic-stack classic to test sophisticated stack technique — the same shape used in their time-series anomaly detection on vote-burst histograms.
- #99hardrarely asked
99. Maximal Rectangle
Find the largest all-1s rectangle in a binary matrix. Reddit uses this to test reduction from 2D to 1D histogram — the same shape used when computing the largest contiguous active region on their heatmap of subreddit activity over time.
- #100hardfrequently asked
100. Minimum Window Substring
Find the smallest substring of s containing all chars of t. Reddit uses this sliding-window hard problem to test the contract-and-expand pattern — the same shape used when searching for the smallest active vote-window covering a target user-set during fraud audits.