← All problemsSign in

Crazy Substrings

CodeChefRating 2126Open on judge ↗

Gotham City is the home of Batman, and Batman likes to keep his people together. There are $N$ houses in the city. The resident of the $i^{th}$ house is of type $A_i$. It is known that people of the same type are friends and people of different types are not friends. To maintain peace, Batman can do the following type of operation: - Choose indices $i$ and $j$ $(1\leq i \le j \le N)$ and rever

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