Skip to content · ⁨Saltar al contenido⁩

Second largest · ⁨Segundo más grande⁩

English

Second largest

Return the second-biggest distinct value. Duplicates of the maximum don't count, so [5, 5, 4] gives 4, not 5.

One clean route: drop duplicates with set(...), sort the result, and take the value one in from the end with [-2].

Español

Segundo mayor

Devuelve el valor distinto segundo más grande. Las duplicaciones del máximo no se cuentan, por lo que [5, 5, 4] da como resultado 4, no 5.

Una vía sencilla: eliminar las duplicidades con set(...), ordenar el resultado y tomar el valor uno antes del final con [-2].

Log in or create account · ⁨Iniciar sesión o crear cuenta⁩

IGCSE, A-Level & AP