Category
Calculate the median of an array of numbers.
Time complexity: O(1)
Space complexity: O(1)
Values to use in the calculation
The median of values
values
Math
const values = [1, 2, 3];median(values); // 2 Copy
const values = [1, 2, 3];median(values); // 2
Calculate the median of an array of bigints.
const values = [1n, 2n, 3n];median(values); // 2n Copy
const values = [1n, 2n, 3n];median(values); // 2n
Calculate the median of an array of numbers.
Time complexity: O(1)
Space complexity: O(1)