+ 1

Can anyone tell me how to remove elements in array which repeats multiple times in array, I have tried didn't work in some cases

For example int a[]={3,4,4,5,3,7,3,3,3}; I want to remove 3 https://code.sololearn.com/cgNtFPOSiZw2/?ref=app https://code.sololearn.com/cgNtFPOSiZw2/?ref=app

2nd Jul 2020, 7:47 AM
Shivam Shiva
Shivam Shiva - avatar
2 Respuestas
0
You can just do 2 nested for loops to compare each number in the array to every number after and if it finds a repeated value, remove it.
2nd Jul 2020, 8:38 AM
JME
0
if you are trying to remove duplicates of one particular element: start loop from 0 after left shift, next number(old i+1) is now on current position(i) loop i++ causes you skip this number so do correct possition for next number as i-- before next loop and check it again then you need only one for() and shift for() inside it
2nd Jul 2020, 2:18 PM
zemiak