Compare two linked lists where each node contains a character array.

Asked atMeta
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 whether chunk boundaries are irrelevant.
  2. 02Keep a node pointer and offset for each list.
  3. 03Compare one character at a time.
  4. 04Advance past exhausted arrays and empty nodes.
  5. 05Accept only when both streams end.

Reference answer

Then expect these follow-ups

  • How would you compare case-insensitively without allocation?

    Tests: follow-up reasoning

  • How would you return the first differing position?

    Tests: implementation extension

Hiring now

Software 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 - Applied AI

    Redwood Software · Hyderabad, Telangana, India

  • Software Engineer - UCD

    Texas Instruments · India

  • Staff Software Engineer

    Inspectorio · Ho Chi Minh, Vietnam

Or practice this question first

Next question