CARS24 On-Campus OA (2024) | Minimum Number of Moves to Seat Everyone

Question · Posted Jun 2026

Problem Statement You are given two integer arrays seats and students of the same length. Each seat can be occupied by exactly one student. In one move, a student can move one position left or right. Return the minimum total number of moves required to seat every student. Example Input seats = [3,1,5] students = [2,7,4] Output 4 Explanation After sorting: seats    = [1,3,5] students = [2,4,7] Moves required: |1-2| = 1 |3-4| = 1 |5-7| = 2 Total ...

The full answer & interview discussion are available to premium members.

Log in Create a free account