11. Remove Duplicates
EasyArrays~7 min
Given an array, return a new array with duplicates removed.
Keep the order of first appearance: the first time a value shows up is the position it should keep.
Examples
Example 1
- Input:
- items = [1, 2, 2, 3, 1]
- Output:
- [1, 2, 3]
Example 2
- Input:
- items = ["a", "b", "a"]
- Output:
- ["a", "b"]
Constraints
0 <= items.length <= 1000Items are numbers or strings.