← All questions
MediumCoding

Find the Maximum Length of Valid Subsequence II

Asked atExpedia
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01State the pairwise validity condition precisely.
  2. 02Bound values by their remainders modulo k.
  3. 03Define DP by ending remainder and required pair residue.
  4. 04Extend only states compatible with the new value.
  5. 05Take the maximum over all states.

Reference answer

Then expect these follow-ups

  • Why is the previous remainder determined by p and r?

    Tests: correctness reasoning

  • Can this state be compressed further?

    Tests: follow-up reasoning

Free to read · better with Enzo

Practice this out loud with Enzo

Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.

Next question