Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up
Problem Submissions Solution

Magnetic Force Between Two Balls

Difficulty: Medium

Acceptance: 60.00%

Points: 30.00

You are given an integer array position[] representing the positions of balls on a number line and an integer m representing the number of balls to place. You must place exactly m balls in the given positions. The magnetic force between two balls is defined as the absolute distance between their positions. Your task is to place the balls such that the minimum magnetic force between any two balls is maximized. Return the maximum possible minimum magnetic force.

Topics

Companies

Articles

Examples:

N/A

Constraints:
  • 2 = position.length = 105
  • 1 = position[i] = 10?
  • All position[i] are distinct
  • 2 = m = position.length
Companies:
Amazon Microsoft Apple Samsung Visa + 1 more
Topics:
Binary Search
Locked Content
Access Restricted: Please Login to access the code editor and test cases.