Solución
solution.tsTypeScript
function findMedian(numbers: number[]): number {
const n = numbers.length
const ns = numbers.toSorted((a, b) => a - b)
if (n & 1) return ns[Math.floor(n / 2)]
return (ns[n / 2 - 1] + ns[n / 2]) / 2
}
// No modificar: necesario para evaluar el resultado.
export { findMedian };0respuestas