Walmart FTE question

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2020-09-13Added By Anonymous
Source: Link

Given an array of integers. Find maximum absolute difference for an element arr[i], such that the difference between the number of integers greater than arr[i] in the range 0 to i-1 and the number of integers lesser than arr[i] in the range i+1 to n is maximum.


no brute force approach


e.g.

input: 1,4,2,7

output: 1


1Input : 2 6 4 1 8 5 7 3 2Output: 4 (maximum difference is for ‘6’ which is 4)
Comments