EPIJ 5.5 Delete duplicates from a sorted array - variant 2


The problem says to modify an array in such a way that entries are limited to appearing min(2, m) times whenever those entries appear m times in the initial unmodified array.

It also restricts the number of passes to one. My question is: Is a valid solution restricted to using no more than a single pointer? The solution I have in mind traverses the array once, but relies on two pointers at the same time to do so, both going left to right. Is this considered two passes or one?

1 Like


Yes, one pass only for this variant.



@tsunghsienlee thanks! but you didn’t answer my question: is using two pointers two passes or one? :slight_smile:



It is tricky, and I think it still is one pass. I think let’s put it straight. It is fine for you to use how many pass. However, try to reduce the number of operations.



Hey, if you have the solution can you please help me
It would really be helpful
I am not able to think how to proceed
Please help me if possible!!