Hi,
I have been given a problem and I just can’t manage to get even close to the solution. I have tried some for loops with if…else statements, but did not do the trick. I am not very good with functions, so I haven’t tried with it. Here is the task:
Given an array of integers, some elements appear twice and others appear once. Each integer is in the range of [1, N], where N is the number of elements in the array.
Find all the integers of [1, N] inclusive that do NOT appear in this array.
Input - Read from the standard input:
There is one line of input, containing N amount of integers, separated by a comma (“,”)
Output - Print to the standard output:
There is one line of output, containing the sorted integers, seperated by a comma (“,”)
Constraints - N will always be in the range of [5, 1000]
Sample Tests
Input Copy - 1,2,3,3,5
Output Copy - 4Input Copy - 4,3,2,7,8,2,3,1
Output Copy - 5,6Input Copy - 1,1,1,1,1,1,1,1
Output Copy - 2,3,4,5,6,7,8
If someone can give any advice how to begin or what pattern I should follow, that would be great.