Skip to content · ⁨דלג לתוכן⁩

Second largest · ⁨השני בגודלו⁩

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].

עברית

השנייה הגדולה ביותר

חזר הערך השני בגודלו המובדל. כפילויות של המקסימום לא נספרות, אז [5, 5, 4] מחזירה 4, לא 5.

דרך נקייה: הסר כפילויות עם set(...), סמן את התוצאה, וחזר על הערך אחד לפני האחרון עם [-2].

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP