Question bank › Monotonic Stack
Dsa Monotonic Stack Hard

Subarray Max Min Difference

Given an array of integers, you need to find the maximum difference between the maximum and minimum elements in all possible contiguous subarrays of the array. Print the maximum difference. For example, for the input [1, 3, 2], the output would be 2 since the maximum (3) and minimum (1) in the subarray [1, 3] gives the difference. Example: Input: 3 1 3 2 Output: 2

Key concepts

monotonic_stacksubarraymin_max

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.