Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Remove duplicates · ⁨ลบ duplicate⁩

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.

ไทย

ลบค่าซ้ำ

return ลิสต์ใหม่ที่เก็บแต่ละค่าไว้เพียงครั้งเดียว ตามลำดับที่มัน ปรากฏครั้งแรก: [1, 1, 2, 3, 3, 1] กลายเป็น [1, 2, 3]

一个 set ตอบคำถาม "เคยเห็นสิ่งนี้ไหม?" ในขั้นตอนเดียวที่รวดเร็ว. Keep a set ของค่าที่เคยเห็นและลิสต์สำหรับผลลัพธ์, และ append ค่าเฉพาะครั้งแรกที่คุณพบมัน

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP