How many segments have max − min ≤ k?
Task
Given an array of numbers and a number k, count the number of contiguous subarrays where max − min ≤ k.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep