#3634

Minimum Removals to Balance Array

specialist · 905 · lc medium +31 · 47.9% accepted · 604 likes · top 33%

Description

An integer array nums and an integer k are given. An array is balanced when its maximum element is at most k times its minimum element.

Remove the fewest elements (without emptying the array) to make it balanced.

Return the minimum removal count. A single-element array is always balanced.

Code

1
2
3