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

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