← All problemsSign in

Gandhiji and Names

Alice and Bob went to Gandhiji with their adopted child and requested him to name her. Gandhiji can choose only two characters Q and H and they should occur the same number of times. The **value** of a name refers to the total number of transitions from 'Q' to 'H' or 'H' to 'Q'. For example, the value of the name **QHQH** is $3$ as it contains $3$ transitions.In this given example, the first tran

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