Menu
CoddyTech

Recap - Remove Duplicates

Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 36 of 78.

challenge icon

Challenge

Easy

Write a function remove_duplicates(numbers: Array[int]) -> Array[int] that returns a new array with every number of numbers once, in the order of its first appearance.

For example, remove_duplicates([1, 2, 2, 3, 4, 4, 5]) returns [1, 2, 3, 4, 5], and remove_duplicates([5, 4, 5, 3, 4]) returns [5, 4, 3].

Use a dictionary as a set to remember the numbers you have already seen. You only write the function: Coddy calls it with different arrays and checks what it returns.

Try it yourself

func remove_duplicates(numbers: Array[int]):
	# Write code here
	pass

All lessons in Logic & Flow

Practice on your own: Online GDScript compiler