#3107

Minimum Operations to Make Median of Array Equal to K

specialist · 960 · lc medium +32 · 47.7% accepted · 165 likes · top 33%

Description

Given an integer array nums and a non-negative integer k, each operation increments or decrements any element by 1. The median is the upper-middle element of the sorted array. Return the minimum operations needed to make the median equal to k.

Code

1
2
3