Answer: EASYREWARDZ On-Campus OA (2024) | Minimum Average Difference
Answer · Posted Jun 2026
Approach Compute: Total sum of array Running prefix sum For every index: leftAvg = prefixSum / (i + 1) rightAvg = (totalSum - prefixSum) / (n - i - 1) For the last index: rightAvg = 0 Track the minimum absolute difference and corresponding index. Strategy Calculate total sum. Traverse the array while maintaining prefix sum. Compute left and right averages. Calculate absolute difference. Update answer if a smaller difference is found. Return the smallest index. Java Code: class Solution ...
The full answer & interview discussion are available to premium members.
Log in Create a free account