You are given an integer array. Return a new array containing only the distinct elements from the original array in the same order they appeared.
Explanation: Distinct elements in the array are 1, 2, 3, 4, 5, and 6, so they are the only elements in the new array.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak