Coding interview questions
156 questions tagged by difficulty. Sign up to unlock full answers and track your weak areas.
- View
Check if a string is a palindrome (ignore case, alphanumeric)
Easy · Coding, Strings, Java 17+
- View
Validate balanced parentheses using a stack
Easy · Coding, Strings, Java 17+
- View
Reverse word order in a sentence in-place style
Easy · Coding, Strings, Java 17+
- View
Longest substring without repeating characters
Medium · Coding, Strings, Java 17+
- View
Compress string with run-length encoding
Medium · Coding, Strings, Java 17+
- View
Count vowels and consonants in a string
Easy · Coding, Strings, Java 17+
- View
Check if s2 is a rotation of s1
Easy · Coding, Strings, Java 17+
- View
Find longest common prefix among strings
Easy · Coding, Strings, Java 17+
- View
Remove all adjacent duplicate characters recursively
Medium · Coding, Strings, Java 17+
- View
Implement atoi string to integer with overflow handling
Hard · Coding, Strings, Java 17+
- View
Two Sum using HashMap
Easy · Coding, Arrays, Java 17+
- View
Rotate array to the right by k steps
Medium · Coding, Arrays, Java 17+
- View
Find missing number in 1..n array
Easy · Coding, Arrays, Java 17+
- View
Find duplicate in array of n+1 integers
Medium · Coding, Arrays, Java 17+
- View
Merge two sorted arrays into one sorted array
Easy · Coding, Arrays, Java 17+
- View
Move all zeros to end while preserving order
Easy · Coding, Arrays, Java 17+
- View
Product of array except self without division
Medium · Coding, Arrays, Java 17+
- View
Maximum subarray sum (Kadane's algorithm)
Medium · Coding, Arrays, Java 17+
- View
Binary search on sorted array
Easy · Coding, Arrays, Java 17+
- View
Intersection of two integer arrays
Easy · Coding, Arrays, Java 17+
- View
Find pair with given sum in unsorted array
Easy · Coding, Arrays, Java 17+
- View
Search insert position in sorted array
Easy · Coding, Arrays, Java 17+
- View
Reverse a String using Streams.
Easy · Coding, Streams, Java 17+
- View
Check if two strings are anagrams using Streams.
Easy · Coding, Streams, Fresher
- View
Find the first non-repeating character in a String using Java 8 Streams.
Medium · Coding, Streams, Senior
- View
Find the frequency of each character in a string using HashMap and Streams.
Easy · Coding, Streams, Fresher
- View
Count occurrences of each word in a sentence (word frequency map).
Easy · Coding, Streams, Fresher
- View
Find duplicate elements in a list using Streams.
Easy · Coding, Streams, Fresher
- View
Remove duplicates from a list using Java 8.
Easy · Coding, Streams, Fresher
- View
Check if a list contains only unique elements using Streams.
Easy · Coding, Streams, Fresher
- View
Find the maximum and minimum element in a list.
Easy · Coding, Streams, Fresher
- View
Find the second highest/lowest element in a list.
Easy · Coding, Streams, Fresher
- View
Find the top N elements in a list using Streams.
Easy · Coding, Streams, Fresher
- View
Sort a Map by values using Streams.
Easy · Coding, Streams, Fresher
- View
Find common elements between two lists using Streams.
Easy · Coding, Streams, Fresher
- View
Flatten a list of lists using flatMap.
Easy · Coding, Streams, Fresher
- View
Merge multiple lists into one using Streams.
Easy · Coding, Streams, Fresher
- View
Convert List<Integer> to comma-separated String using Collectors.
Easy · Coding, Streams, Fresher
- View
Partition numbers into even/odd using Collectors.partitioningBy.
Easy · Coding, Streams, Fresher
- View
Group employees by department using Collectors.groupingBy.
Medium · Coding, Streams, Senior
- View
Find the average salary of employees using Streams.
Easy · Coding, Streams, Fresher
- View
Find the longest string in a list using reduce().
Easy · Coding, Streams, Fresher
- View
Count the number of words in a file using parallelStream().
Medium · Coding, Streams, Concurrency
- View
Convert a list into a Map using Collectors.toMap().
Medium · Coding, Streams, Senior
- View
Custom sort an Employee list by salary and then by name.
Medium · Coding, Collections, Java 8+
- View
Implement a custom Comparator with multiple fields (department, salary descending, name).
Medium · Coding, Collections, Java 8+
- View
Implement an LRU Cache using LinkedHashMap.
Hard · Coding, Collections, Architect
- View
Design a bounded blocking queue from scratch.
Hard · Coding, Collections, Concurrency
- View
Sort map entries by frequency descending.
Medium · Coding, Collections, Senior
- View
Top K frequent elements using PriorityQueue.
Medium · Coding, Collections, Senior
- View
Range query on TreeMap using subMap.
Medium · Coding, Collections, Senior
- View
Create a defensive immutable copy of a list (Java 17+).
Easy · Coding, Collections, Java 17+
- View
Deque-based sliding window maximum.
Hard · Coding, Collections, Staff
- View
Thread-safe iteration with CopyOnWriteArrayList demo.
Medium · Coding, Collections, Concurrency
- View
Implement a stack using an array.
Easy · Coding, Data Structures, Stack
- View
Implement a queue using two stacks.
Medium · Coding, Data Structures, Queue
- View
Reverse a singly linked list iteratively.
Easy · Coding, Data Structures, Linked List
- View
Detect a cycle in a linked list (Floyd's algorithm).
Medium · Coding, Data Structures, Linked List
- View
Merge two sorted linked lists.
Medium · Coding, Data Structures, Linked List
- View
Validate a binary search tree.
Medium · Coding, Data Structures, Binary Tree
- View
Binary tree level-order traversal (BFS).
Medium · Coding, Data Structures, Binary Tree
- View
Invert a binary tree recursively.
Easy · Coding, Data Structures, Binary Tree
- View
Find the kth largest element using a min-heap.
Medium · Coding, Data Structures, Heap
- View
Design a HashMap with separate chaining.
Hard · Coding, Data Structures, HashMap
- View
Compute Fibonacci numbers with memoization.
Easy · Coding, Recursion, DP
- View
Compute factorial iteratively and recursively.
Easy · Coding, Recursion, Fresher
- View
Generate all permutations of an array.
Medium · Coding, Recursion, Backtracking
- View
Generate the power set via backtracking.
Medium · Coding, Recursion, Backtracking
- View
Solve the Tower of Hanoi puzzle.
Medium · Coding, Recursion, Senior
- View
Climbing stairs — count distinct ways (DP).
Easy · Coding, Recursion, DP
- View
Coin change — minimum number of coins (DP).
Hard · Coding, Recursion, DP
- View
N-Queens — count the number of solutions.
Hard · Coding, Recursion, Backtracking
- View
Implement merge sort (divide and conquer).
Medium · Coding, Algorithms, Sorting
- View
Implement quicksort with Lomuto partition.
Medium · Coding, Algorithms, Sorting
- View
Sliding window maximum.
Hard · Coding, Algorithms, Deque
- View
Longest increasing subsequence length in O(n log n).
Hard · Coding, Algorithms, DP
- View
Topological sort using Kahn's algorithm.
Hard · Coding, Algorithms, Graph
- View
BFS shortest path in an unweighted graph.
Medium · Coding, Algorithms, Graph
- View
DFS cycle detection in a directed graph.
Medium · Coding, Algorithms, Graph
- View
Sort colors — Dutch national flag algorithm.
Medium · Coding, Algorithms, Array
- View
Implement a producer-consumer pattern using BlockingQueue.
Medium · Coding, Concurrency, Collections
- View
Print odd and even numbers alternately using two threads.
Medium · Coding, Concurrency, Senior
- View
Demonstrate asynchronous computation using CompletableFuture.
Medium · Coding, Concurrency, Java 8+
- View
Implement a thread-safe Singleton using Bill Pugh and Double-Checked Locking patterns.
Hard · Coding, Concurrency, Design Principles
- View
Implement a barrier for 3 threads using CyclicBarrier.
Hard · Coding, Concurrency, Staff
- View
Write a program where 3 threads print A, B, C in sequence repeatedly.
Hard · Coding, Concurrency, Staff
- View
Implement a multithreaded word counter using ConcurrentHashMap.
Hard · Coding, Concurrency, Collections
- View
ExecutorService fixed thread pool task submission.
Medium · Coding, Concurrency, Senior
- View
ReadWriteLock for cache read-heavy workload.
Hard · Coding, Concurrency, Architect
- View
CountDownLatch service startup coordinator.
Medium · Coding, Concurrency, Senior
- View
Semaphore-based rate limiter.
Hard · Coding, Concurrency, Architect
- View
Virtual threads (Java 21) for concurrent HTTP-style tasks.
Medium · Coding, Concurrency, Java 21
- View
Builder pattern for an immutable object.
Medium · Coding, OOP & Patterns, Builder
- View
Strategy pattern for sorting comparators.
Medium · Coding, OOP & Patterns, Strategy
- View
Factory method pattern.
Medium · Coding, OOP & Patterns, Factory Method
- View
Observer pattern — event bus.
Medium · Coding, OOP & Patterns, Observer
- View
Java 17 record as a DTO with validation.
Easy · Coding, OOP & Patterns, Records
- View
Sealed classes with pattern matching.
Medium · Coding, OOP & Patterns, Sealed Classes
- View
Template method for data export.
Medium · Coding, OOP & Patterns, Template Method
- View
Decorator pattern — coffee pricing.
Medium · Coding, OOP & Patterns, Decorator
- View
Check if two strings are anagrams (character frequency)
Easy · Coding, Strings, HashMap
- View
Group anagrams from a list of strings
Easy · Coding, Strings, HashMap
- View
Find all unique triplets that sum to zero (3Sum)
Medium · Coding, Strings, Two Pointers
- View
Minimum window substring containing all characters of t
Hard · Coding, Strings, Sliding Window
- View
Find the longest palindromic substring
Medium · Coding, Strings, Two Pointers
- View
Container with most water (two pointers)
Medium · Coding, Arrays, Two Pointers
- View
Trapping rain water between elevation bars
Hard · Coding, Arrays, Two Pointers
- View
Count subarrays with sum equal to k (prefix sum + HashMap)
Medium · Coding, Arrays, Prefix Sum
- View
Count number of islands in a 2D grid (DFS/BFS)
Medium · Coding, Graphs, DFS
- View
Number of connected components using Union-Find
Medium · Coding, Graphs, Union-Find
- View
Dijkstra's shortest path in a weighted graph
Hard · Coding, Graphs, Graph
- View
Word Search — find word in 2D grid (backtracking)
Medium · Coding, Graphs, Backtracking
- View
Alien Dictionary — derive character order from sorted words (topo sort)
Hard · Coding, Graphs, Graph
- View
Word Ladder — shortest transformation sequence (BFS)
Hard · Coding, Graphs, BFS
- View
House Robber — maximum loot without adjacent houses
Easy · Coding, Dynamic Programming, DP
- View
Longest Common Subsequence (LCS)
Medium · Coding, Dynamic Programming, DP
- View
0/1 Knapsack — maximum value with weight limit
Medium · Coding, Dynamic Programming, DP
- View
Edit Distance (Levenshtein) between two strings
Hard · Coding, Dynamic Programming, DP
- View
Decode Ways — count ways to decode a digit string (1-26 → A-Z)
Medium · Coding, Dynamic Programming, DP
- View
Merge overlapping intervals
Medium · Coding, Intervals, Sorting
- View
Non-overlapping intervals — minimum removals to eliminate overlap
Medium · Coding, Intervals, Greedy
- View
Meeting Rooms II — minimum conference rooms required
Medium · Coding, Intervals, Heap
- View
Find the single number (every other appears twice) using XOR
Easy · Coding, Bit Manipulation, Fresher
- View
Count set bits (Hamming weight) in an integer
Easy · Coding, Bit Manipulation, Fresher
- View
Check if a number is a power of two
Easy · Coding, Bit Manipulation, Fresher
- View
Search in rotated sorted array
Medium · Coding, Binary Search, Senior
- View
Koko Eating Bananas — binary search on answer
Medium · Coding, Binary Search, Staff
- View
Jump Game II — minimum jumps to reach last index
Medium · Coding, Greedy, BFS
- View
Jump Game I — can you reach the last index?
Medium · Coding, Greedy, Senior
- View
Activity Selection — maximum non-overlapping intervals
Medium · Coding, Greedy, Intervals
- View
Next Greater Element for each array position
Medium · Coding, Monotonic Stack, Stack
- View
Daily Temperatures — days until warmer temperature
Medium · Coding, Monotonic Stack, Stack
- View
Largest rectangle in histogram
Hard · Coding, Monotonic Stack, Stack
- View
Spiral matrix traversal
Medium · Coding, Matrix, Senior
- View
Validate a 9×9 Sudoku board
Medium · Coding, Matrix, HashSet
- View
Set matrix zeroes in-place
Medium · Coding, Matrix, Senior
- View
Implement Trie (Prefix Tree) with insert, search, startsWith
Medium · Coding, Trie, Senior
- View
Word Search II — find all words from dictionary in grid (Trie + DFS)
Hard · Coding, Trie, Backtracking
- View
Maximum depth of a binary tree
Easy · Coding, Data Structures, Binary Tree
- View
Lowest Common Ancestor in a BST
Easy · Coding, Data Structures, BST
- View
Serialize and deserialize a binary tree
Hard · Coding, Data Structures, Binary Tree
- View
Diameter of a binary tree (longest path between any two nodes)
Medium · Coding, Data Structures, Binary Tree
- View
Merge k sorted linked lists
Hard · Coding, Data Structures, Heap
- View
Find median from a data stream (two heaps)
Hard · Coding, Data Structures, Heap
- View
Root-to-leaf path sum equals target
Easy · Coding, Data Structures, Binary Tree
- View
Design Hit Counter — count hits in past 5 minutes
Medium · Coding, System Design Coding, Queue
- View
Design Twitter feed — merge k sorted post streams
Hard · Coding, System Design Coding, Heap
- View
Consistent hashing — locate key on a server ring
Hard · Coding, System Design Coding, Distributed Systems
- View
Distributed unique ID generator (Snowflake-style)
Hard · Coding, System Design Coding, Distributed Systems
- View
Idempotent API handler with idempotency keys
Medium · Coding, System Design Coding, Design
- View
Circuit breaker pattern implementation
Medium · Coding, System Design Coding, Design
- View
Platform plugin registry — load and invoke extensions safely
Hard · Coding, System Design Coding, Platform
- View
Schema registry — validate and version event payloads
Hard · Coding, System Design Coding, Platform
- View
Policy engine — evaluate allow/deny rules on requests
Hard · Coding, System Design Coding, Platform
- View
Median of two sorted arrays (binary partition)
Hard · Coding, System Design Coding, Binary Search
- View
Saga orchestration — coordinate distributed transactions
Hard · Coding, System Design Coding, Distributed Systems