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
55 practiced
Given a string s, implement length_of_longest_substring(s) in Python that returns the length of the longest substring without repeating characters (classic sliding-window). Explain why sliding-window + hashmap is O(n). Example: s='abcabcbb' -> 3 for 'abc'. Also mention how to return the substring itself.
MediumTechnical
51 practiced
Implement longest_palindrome_substring(s) using Manacher's algorithm for O(n) time, or provide a dynamic programming O(n^2) solution if Manacher is unfamiliar. The function should return the longest palindromic substring. Example: s='babad' -> 'bab' or 'aba'. Explain time/space tradeoffs.
MediumTechnical
64 practiced
Detect cycle in a linked list and return the node where the cycle begins (Linked List Cycle II) in Python. Use Floyd's Tortoise and Hare algorithm to detect cycle and compute the start node in O(n) time and O(1) space. Provide an example and explain why resetting one pointer to head works.
MediumTechnical
54 practiced
Implement find_peak_element(nums) in Python to find a peak element (element strictly greater than neighbors) and return its index in O(log n) time using binary search-like approach. Example: nums=[1,2,3,1] -> index 2. Discuss invariants that guarantee correctness on boundaries.
EasyTechnical
60 practiced
Given a string containing characters '(', ')', '{', '}', '[' and ']', implement is_valid(s) in Python to determine if the input string is valid. A string is valid if brackets are closed in the correct order. Example: s = '([{}])' -> True. Aim for O(n) time and O(n) space. Include handling of odd lengths and unexpected characters.

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.