Description

An array arr is given. Each element of arr is a number between 0 through 9. You want to remove all the duplicate numbers in the array arr except for only one. However, the order of each element in the array arr should be maintained. For example,

  • When arr = [1, 1, 3, 3, 0, 1, 1], return [1, 3, 0, 1].
  • When arr = [4, 4, 4, 3, 3], return [4, 3].

Write a function solution to return the remaining numbers after removing the duplicate numbers in the array arr except only one.

Constraints
  • Length of array arr : natural number less than or equal to 1,000,000.
  • Element of array arr : integer between 0 and 9.

Examples
arr answer
[1,1,3,3,0,1,1] [1,3,0,1]
[4,4,4,3,3] [4,3]

Example #1,2
It is the same as the example in the problem statement.

Result Stop
Result of [Run Test] or [Submit] will be displayed here
내가 제출한 코드가 왜 틀렸는지 프로그래머스 AI에게 물어보세요.
제출 후 채점하기를 눌러 30점 이상인 경우 물어볼 수 있어요.
베타 기간 동안에는 한 문제당 1번만 물어볼 수 있어요.