Find a Subsequence
Given an array A of N integers A[0], A[1], ..., A[N-1] and a string B which is a permutation of "12345". You have to find a subsequence of 5 elements from A having distinct values such that their relative order is same as B. Meaning that, if (i0, i1, i2, i3, i4) are the indexes of such a subsequence (0 0 1 2 3 4 then: - A[i0] is the B[0]-th smallest element among the 5 numbers. - A[i1] is the
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.
Sign in to chat with the tutor and save your progress.
Sign in to start