Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 6
first take the input from the user(in the form of a list)
then sort it using the 'sort()' syntax
then you can use the for loop and print all the values of i which are not in the list
"According to me this is the simplest method". NO NEED OF DOING THINGS COMPLEX.
+ 2
Yes
+ 2
It took me 14 lines so probably didn't break any records but it was fun :-)
N_input = int(input())
element_list = []
for n_in in range(N_input):
element_list.append(int(input()))
full_string = []
ind = min(element_list)
while ind < max(element_list) + 1:
full_string.append(ind)
ind += 1
out_string = ''
for element in full_string:
if element not in element_list:
out_string += str(element) + ' '
print(out_string[:-1])
+ 1
+1
+ 1
+1
+ 1
Haven't done it yet, I'll give it a try