You get a list of integers nums. Some values may appear more than once.
Return a new list that has each value only once.
Keep the first copy of each value and drop the later ones. The values stay in the order they first appear in nums.
Example 1:
Input: nums = [3, 1, 3, 2, 1] Output: [3, 1, 2] Explanation: The second 3 and the second 1 are repeats. They are dropped, and 3, 1 and 2 stay in their order.
Example 2:
Input: nums = [6, 6, 6, 6] Output: [6] Explanation: Only the first 6 stays.
Example 3:
Input: nums = [4, 9, 2] Output: [4, 9, 2] Explanation: No value repeats, so every number stays.
Constraints:
numshas at least one number.- Every number is between -109 and 109.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
