Questions › Technical PM › Top-Interview
Given an array of integers and a number N, find the length of the longest contiguous subarray such that the difference between any two elements in the subarray is less than N.
- Technical PM
- Top-Interview
- Hard
- 15 min
Focus on developing an efficient algorithm to solve the problem, ideally in linear time. Start by clarifying the constraints of the input array and the value of N. Use a sliding window approach to maintain a range of valid elements while iterating through the array. Keep track of the minimum and maximum values within the current window to check if their difference is less than N. Be prepared to discuss edge cases, such as arrays with all identical elements or when N is very small. Finally, explain your thought process clearly, detailing how you would implement and optimize your solution.
What this question tests
- Technical PM
- Structured problem solving
- Communication
- Trade-off reasoning
Practise this question under interview conditions. Answer it out loud against a timer with an AI interviewer that asks follow-ups, then review the scored report.
Related Technical PM questions
- Design a file upload feature for an AI chat application.Top-Interview · Technical PM · Hard
- Given a string s, return true if the s can be a palindrome after deleting at most one character from it.Top-Interview · Technical PM · Hard
- If you were building an autocomplete experience, how would you use underlying data to predict the next word a person is going to type?Top-Interview · Technical PM · Hard
- Implement a streaming database with the given constraints and requirements.Top-Interview · Technical PM · Hard
- What LLMs or AI agents do you use, and why?Top-Interview · Technical PM · Hard
- A production service started showing errors and timeouts after a deployment. How would you troubleshoot it?Top-Interview · Technical PM · Hard
All Technical PM questions · Product manager interview questions by skill area