This is a verified interview question from Zomato. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Minimum Steps to Equalize Array Elements - Zomato Eternal Online Assessment MANIT Bhopal" covers key patterns like Other.
"### Pattern: 3dsa + 12 MCQS 90 min You are given an array A of N integers. Each element in the array has a value between 1 and K. You can change the value of any element by incrementing or decrementing it by 1 in a single step. The values are circular, meaning: * If A[i] = 1, you can move to 2 or wrap around to K in 1 step. * If A[i] = K, you can move to K - 1 or wrap around to 1 in 1 step. * Otherwise, you can move to A[i] - 1 or A[i] + 1 in 1 step. Find the minimum total number of steps required to make all elements in the array equal. ### Input Format The first line contains two integers, N (the size of the array) and K (the maximum value in the circular range). The second line contains N space-separated integers representing the array A. ### Output Format Print a single integer representing the minimum number of steps to equalize the array."
Join thousands of developers practicing for Zomato.