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.

MediumTechnical
48 practiced
Decode Ways: given a string s containing only digits, implement num_decodings(s) in Python to return the number of ways to decode it (mapping 1->'A', 2->'B', ..., 26->'Z'). Use DP with O(n) time and O(1) space. Example: s='226' -> 3 ('2-2-6', '22-6', '2-26'). Handle zeros carefully.
MediumTechnical
92 practiced
Implement check_inclusion(s1, s2) in Python: given two strings, return True if s2 contains a permutation of s1. This is equivalent to checking if any substring of s2 is an anagram of s1. Use sliding-window + character counts in O(n) time. Example: s1='ab', s2='eidbaooo' -> True.
MediumTechnical
56 practiced
Implement a function to find the first missing positive integer in unsorted array nums in O(n) time and O(1) extra space (Cyclic Sort / index placement technique). Example: [3,4,-1,1] -> 2. Explain how to map values to indices and why this achieves linear time.
MediumTechnical
63 practiced
Product of Array Except Self: implement product_except_self(nums) in Python that returns an array output where output[i] is product of all elements in nums except nums[i]. Do this without division in O(n) time and O(1) extra space (output doesn't count). Example: [1,2,3,4] -> [24,12,8,6]. Handle zeros correctly.
MediumTechnical
49 practiced
Given a list of points in the plane, implement k_closest(points, k) in Python to return k points closest to origin (0,0) by Euclidean distance. Discuss quickselect (average O(n)) vs heap (O(n log k)). Example: points=[[1,3],[-2,2]], k=1 -> [[-2,2]]. Handle ties deterministically.

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.