0

There are repeated elements in an array.Print each element exactly once in the order given in the input array.

without using extra space. numbers are between 0 to n-1 . n is the size of array

13th Nov 2016, 9:34 PM
shivam khare
shivam khare - avatar
3 odpowiedzi
+ 2
arr= [2,4,4,3,5,5,4,4] narr= [] for x in arr: if x not in narr: narr.append(x) print(narr)
13th Nov 2016, 10:14 PM
damilare lamidi
damilare lamidi - avatar
+ 1
Use print(n for n in narr) instead of print(narr)
14th Nov 2016, 8:52 AM
damilare lamidi
damilare lamidi - avatar
0
u can't take extra space
13th Nov 2016, 10:17 PM
shivam khare
shivam khare - avatar