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

Remove duplicates · ⁨הסרת כפילויות⁩

English

Remove duplicates

Return a new list that keeps each value only once, in the order it first appeared: [1, 1, 2, 3, 3, 1] becomes [1, 2, 3].

A set answers "have I seen this already?" in one fast step. Keep a set of seen values and a list for the result, and only append a value the first time you meet it.

עברית

הסרת כפילויות

חזר רשימה חדשה ששומרת על כל ערך רק פעם אחת, בסדר הופעתו הראשון: [1, 1, 2, 3, 3, 1] הופך ל-[1, 2, 3].

set משיב "האם ראיתי זאת כבר?" בשלב מהיר אחד. שמור set של ערכים שנראו ורשימה לתוצאה, והוסף ערך רק בפעם הראשונה שמתקבלים עליו.

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

IGCSE, A-Level & AP