← All problemsSign in

Reduce to Palindrome

CodeChefRating 2830Open on judge ↗

A binary string $S$ is said to be *good* if it can be converted into a palindrome$^\dagger$ by performing the following operation several (possibly zero) times: - Choose two adjacent equal characters in $S$ and delete them. Formally, choose an index $i$ ($1 \leq i \lt |S|$) such that $S_i = S_{i+1}$, and delete $S_i$ and $S_{i+1}$ from $S$, without changing the order of the other elements. For

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