Two-Pointer Based

Asked atAAugnitoCisco MerakiMicrosoft
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. 01Clarify the target operation and data ordering.
  2. 02Choose endpoints or a lead-lag gap.
  3. 03Maintain a stated candidate invariant.
  4. 04Advance each pointer at most once per index.

Reference answer

Then expect these follow-ups

  • When would hashing beat sorting plus pointers?

    Tests: tradeoffs

  • How do you handle duplicate pairs?

    Tests: deduplication

Hiring now

Backend engineer roles are open 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 Engineer, Backend

    Mirage · Union Square, New York City

  • Backend / Systems Engineer, Agent Infrastructure

    Clera · Berlin

  • Senior Backend Software Engineer I

    Delivery Hero · Singapore, Singapore

Or practice this question first

Next question