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
53 practiced
Kth Smallest Element in Two Sorted Arrays: given two sorted arrays A (length m) and B (length n) and integer k (1 <= k <= m+n), implement find_kth(A, B, k) in Python that returns the kth smallest element in O(log(m+n)) time. Explain your partition/binary-search approach and handle edge cases.
HardTechnical
52 practiced
Alien Dictionary: given a list of words sorted lexicographically according to an unknown alien alphabet, implement alien_order(words) in Python to derive a valid ordering of the characters. Build a graph of precedence edges by comparing adjacent words and perform a topological sort; detect invalid cases such as a prefix ordering that is impossible. Return an ordering string or empty if invalid.
MediumTechnical
52 practiced
Course Schedule II (topological sort): given numCourses and prerequisites list pairs [a,b] meaning take b before a, implement find_order(numCourses, prerequisites) in Python to return a valid ordering or an empty list if impossible. Use Kahn's algorithm or DFS topological sort; explain cycle detection and complexity.
HardTechnical
50 practiced
Design and implement an LRU cache in Python with methods get(key) and put(key, value) that both run in O(1) average time. The cache should evict the least-recently-used item when capacity is exceeded. Provide classes and explain your combination of a hash map and doubly-linked list. Discuss thread-safety and TTL extension considerations for production systems.
EasyTechnical
87 practiced
Given the head of a sorted singly-linked list, implement delete_duplicates(head) in Python that deletes duplicate nodes such that each element appears only once. Return the head of the updated list. Target O(n) time and O(1) extra space. Example: input 1->1->2->3->3 -> output 1->2.

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.