← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
PayPal's "Minimum Steps to Move Balls to Holes" is a coding problem solvable with greedy and two-pointer techniques on arrays. It requires calculating the minimum moves to match balls to holes via adjacent steps.
Given two arrays of equal length—one for ball positions (balls) and one for hole positions (holes)—both sorted in ascending order, compute the minimum total steps needed to move all balls into their respective holes. Each step moves a ball one unit left or right to an adjacent position, and balls move independently without colliding. Assign the i-th ball to the i-th hole (fixed pairing).[1]
Example 1:
Input: balls = [1,3,5], holes = [2,4,6]
3[1]Example 2:
Input: balls = [1,2,5], holes = [2,3,4]
3[1]1 <= balls.length == holes.length <= 10^51 <= balls[i], holes[i] <= 10^9