PMMockr

QuestionsTechnical PMTop-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.

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

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.

Start a timed mock interview

Related Technical PM questions

All Technical PM questions · Product manager interview questions by skill area