Search
⌘K
Get Premium
Leetcode 2256. Minimum Average Difference
Compute, for each index i, the absolute difference between the floor average of the first i+1 elements and the floor average of the remaining elements (treating the average of 0 elements as 0), and return the smallest index with the minimum difference. This is efficiently done by using running prefix sums and the total sum to get prefix/suffix averages in O(n) time.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.