Company: Visa_27oct
Difficulty: medium
Smallest Peak Height Difference A mountaineer is surveying a mountain range. The peaks stand in a line and are numbered 0, 1, ..., n-1 from left to right; peak i is heights[i] meters tall. An optical illusion makes nearby peaks impossible to tell apart, so the mountaineer can only compare two peaks when they are at least viewingGap positions apart . Formally, peaks a and b form a comparable pair when |a - b| >= viewingGap . Among all comparable pairs, report the smallest height difference — the minimum value of |heights[a] - heights[b]| over every pair of positions a , b with |a - b| >= viewingGap . Because viewingGap is always smaller than the number of peaks, at least one comparable pair always exists. Input Format The first line contains a single integer n , the number of peaks. The second line contains n space-separated integers heights[0] ... heights[n-1] . The third line contains a single integer viewingGap . Output Format Print a single integer — the smallest height differ