InterviewStack.io LogoInterviewStack.io

Medium Difficulty Coding Problems Questions

Practice and master medium difficulty algorithmic coding problems that commonly appear in technical interviews. Topics include arrays, strings, linked lists, trees, graphs, hash tables, and dynamic programming. Typical techniques to know are two pointer methods, sliding window, breadth first search and depth first search, recursion and backtracking, memoization and bottom up dynamic programming, sorting and greedy heuristics, and common data structure operations. Interviewers evaluate systematic problem solving: clarifying requirements, designing a correct solution, explaining time and space complexity, handling edge cases and input validation, writing clean and working code in your chosen language, and then iterating to optimize performance. Candidates should be comfortable explaining tradeoffs between approaches, testing with example cases, and communicating thought process clearly while coding under time constraints.

EasyTechnical
47 practiced
Two Sum (hash-table, O(n) expected): Given an integer array nums and an integer target, implement a function in your chosen language (Python/Java/C++) that returns indices of the two numbers such that they add up to target. Assume exactly one solution and you may not use the same element twice. Example: nums = [2,7,11,15], target = 9 -> [0,1]. Explain time and space complexity and discuss edge cases (empty input, negative numbers, duplicates).
HardTechnical
53 practiced
Minimum Window Substring (hard sliding-window): Given strings s and t, find the minimum window substring in s which contains all characters in t (including multiplicities). Implement the optimal sliding-window approach using two pointers and frequency maps to expand and shrink the window. Discuss handling of character multiplicity, large alphabets, and why this approach is near-optimal.
HardTechnical
88 practiced
K-th Shortest Path in Weighted Directed Graph (allowing revisits): Given a weighted directed graph, source node, target node and integer k, compute the length of the k-th shortest path from source to target (paths may revisit nodes). Implement modified Dijkstra/A* style algorithm using a min-heap and a count of times each node is popped; stop when target has been popped k times. Assume non-negative weights and explain complexity analysis.
MediumTechnical
47 practiced
Merge Intervals (meeting room merging): Given an array of intervals where each interval is [start, end], merge all overlapping intervals and return the merged list. Implement by sorting intervals by start time then iterating once to merge. Provide code and discuss handling of inclusive/exclusive boundaries and large input size considerations.
MediumTechnical
54 practiced
Sliding Window Maximum (monotonic deque): Given an integer array nums and window size k, return an array of the maximums for every sliding window of size k. Implement an O(n) solution using a deque that stores indices of useful candidates and keeps them in decreasing order. Explain edge cases when k > n and how to handle ties.

Unlock Full Question Bank

Get access to hundreds of Medium Difficulty Coding Problems interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.