Remove Duplicates and Print
mediumQuestion 121An array called nums has already been created for you with the values {10, 20, 10, 30, 20}.
Your task is to print only the unique values: the first time each number appears. If a number has already appeared earlier in the array, skip it.
For each element, you need to check whether it appeared at any earlier index. If it did, don't print it. If it didn't, print it.
In this array: - 10 at index 0: first time → print - 20 at index 1: first time → print - 10 at index 2: already appeared at index 0 → skip - 30 at index 3: first time → print - 20 at index 4: already appeared at index 1 → skip
Print the unique values on one line separated by spaces.
Expected output
10 20 30 = newline. No newline after the last line.
Hints4 available
Sign in to use hintsTopics
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.