Two Sum
Find indices of two array elements summing to target. Compare O(n²) brute-force scanning against O(n) one-pass complement lookup with a Hash Map.
Study 31 core interview problems grouped by algorithmic pattern. Each problem compares brute-force and optimal complexity, walks through concrete execution traces, highlights boundary edge cases, and provides implementations in Python, JavaScript, Java, C++, and C.
Filter by pattern, difficulty, or study status to inspect complexity trade-offs, trace steps, and implementations.
Find indices of two array elements summing to target. Compare O(n²) brute-force scanning against O(n) one-pass complement lookup with a Hash Map.
Check whether any integer repeats inside an array. Compare early-exit O(n) Hash Set membership testing against O(1)-space in-place sorting.
Check whether string t is an anagram of string s. Compare O(n log n) canonical sorting against an O(n) fixed 26-letter frequency bucket balance.
Compute the array of products excluding each element without division. Progress from separate left/right product arrays to O(1) auxiliary space.
Extract the k most frequent integers in an array. Compare a size-K Min-Heap over frequency counts with O(n) frequency-indexed Bucket Sort.
Locate a target value inside an unsorted array by scanning elements sequentially. Compare standard index-bounded scanning with Sentinel Loop optimization.
Locate a target value in a sorted array in O(log n) time by repeatedly bisecting the search interval. Compare iterative vs recursive implementations and overflow guards.
Locate a target inside a rotated sorted array in O(log n) time. Compare pivot-split binary search against single-pass sorted-half elimination.
Check whether a string reads identically forward and backward over alphanumeric characters. Compare build-and-reverse against O(1)-space converging pointers.
Find all unique integer triplets summing to zero. Compare hash-set pair lookup against sorting + two-pointer inward scans with duplicate skipping.
Find two vertical walls bounding maximum water volume. Compare quadratic pair enumeration against O(n) greedy two-pointer elimination.
Calculate total trapped water between elevation bars. Compare O(n)-space prefix/suffix max arrays with O(1)-space converging two pointers.
Find the longest contiguous substring with all distinct characters. Compare shrinking-set sliding windows against O(1) direct left-pointer jumps via an index map.
Check whether brackets (), {}, and [] match in proper nested LIFO order. Compare iterative innermost-pair collapse against O(n) stack validation.
Design a LIFO stack supporting push, pop, top, and getMin in O(1) time. Compare a synchronized parallel min stack against a sparse minimum-change stack.
Reverse a singly linked list in-place by flipping next pointers. Compare O(1)-space three-pointer iteration with recursive tail rewiring.
Splice two sorted linked lists together into one non-decreasing linked list. Compare O(1)-space iterative dummy-head splicing against recursive pointer linking.
Detect whether a linked list loops back on itself. Compare O(n)-space node-identity tracking against Floyd's O(1)-space fast-and-slow pointer algorithm.
Mirror a binary tree around its vertical axis by swapping left and right child pointers via recursive DFS or iterative level-order BFS.
Compute the maximum depth (node count along longest root-to-leaf path) of a binary tree using recursive post-order DFS and iterative level-order BFS.
Check whether subRoot matches an entire subtree of root in structure and values. Compare double-DFS tree matching against O(n + m) pre-order serialization + substring search.
Group binary tree node values level-by-level from left to right. Compare FIFO queue level batching against depth-indexed DFS recursion.
Locate the lowest common ancestor of nodes p and q inside a Binary Search Tree. Compare recursive BST branching against an O(1)-space iterative root-to-split walk.
Count disconnected landmasses across a 2D binary grid using connected-component traversal. Compare in-place DFS flood fill against iterative BFS.
Find minimum minutes for all fresh oranges to rot via 4-directional spreading. Compare in-place O(1)-space round simulation with optimal Multi-Source BFS.
Locate the kth largest integer in an unsorted array without full sorting. Compare a size-K streaming Min-Heap with average-O(n) Randomized Quickselect.
Maximize single-transaction stock profit across daily prices by contrasting pairwise brute force with a one-pass running-minimum tracker.
Find the contiguous subarray with the largest integer sum. Compare quadratic prefix enumeration against Kadane's linear-time reset invariant.
Count distinct ways to climb n stairs taking 1 or 2 steps at a time. Progress from top-down memoization to O(1)-space Fibonacci dynamic programming.
Find the minimum number of coins required to form a target amount. Compare top-down memoized search against bottom-up unbounded knapsack tabulation.
Merge all overlapping intervals into sorted non-overlapping ranges. Compare graph component grouping against sorting by start time + greedy scan.
Master contiguous memory collections, frequency maps, prefix sums, and O(1) hash lookups.
Converge or stagger two indices over sorted and linear datasets to eliminate quadratic passes.
Expand and contract dynamic contiguous subsegment boundaries to track running subarray states.
Leverage Last-In, First-Out (LIFO) stacks for bracket validation, postfix evaluation, and monotonic runs.
Divide and conquer ordered search spaces to isolate targets and boundaries in logarithmic time.
Manipulate sequential pointer node chains, pointer reversal, and fast-and-slow runner techniques.
Traverse hierarchical node structures with DFS recursion, BFS level order, and binary search tree invariants.
Maintain min/max heap tree invariants for instant Top-K extractions and running stream medians.
Model interconnected vertices, grid traversals, cycle detection, topological sorting, and shortest paths.
Break complex combinatorial problems into overlapping subproblems with memoization and tabulation.