← 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

Hiring now

Expedia has 109 open roles right now

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
  • Software Development Engineer III - Platform Productivity Tools

    India - Gurgaon

  • Sr Manager, Software Engineering

    Austin Domain 11 - HomeAway

  • Software Development Engineer II

    India - Gurgaon

Or practice this question first

Next question