← All problemsSign in

Remove and Add

CodeChefRating 1877Open on judge ↗

You are given an array $A$ of $N$ integers. You must perform some (possibly zero) operations to make the elements of $A$ distinct. In one operation, you can either: - Remove one element from the beginning of the array $A$ and append any positive integer to the end. - Or remove one element from the end of the array $A$ and prepend any positive integer to the beginning. Find the minimum number of

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start