← All problemsSign in

Strings and Graphs

CodeChefRating 2300Open on judge ↗

Consider a sequence of positive integers A = (A1, A2, ... , AN), and another sequence B = (B1, B2, ... , BM). We say that B is a subsequence of A, if B can be written as (Ai1, Ai2, ... , AiM), where 1 ≤ i1 2 ... M ≤ N. If B is a subsequence of A, there could be multiple ways to write it in such a manner, and among all those ways, we choose the way which minimizes iM. We call this minimized iM to b

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