Solución
solution.tsTypeScript
function maxProduct(nums: number[]): number {
const orderedNums = [...nums].sort((a, b) => a - b)
const last = orderedNums.length - 1
return Math.max(
orderedNums[0] * orderedNums[1],
orderedNums[last] * orderedNums[last - 1]
);
}
// No modificar: necesario para evaluar el resultado.
export { maxProduct };0respuestas