← All problemsSign in

Fun with Numbers

You are given a string $S$ of length $N$ where each character $S$i ($1 \leq i \leq N$) is either $0$ , $1$ or $2$. You can do the following operations on the string : 1. Change at most $x$ 0’s to either 1 or 2 2. Change at most $y$ 1’s to either 0 or 2 3. Change at most $z$ 2’s to either 0 or 1 You need to find the maximum length of the substring for a given $x,y,z$ such that all elements in the s

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