← Apple Interview Insights

Apple·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Apple SWE interview with a linked list intersection problem that sounds easy until you're actually sitting there trying to explain pointer arithmetic and memory tradeoffs out loud. The two-pointer approach is well-known but they wanted more than just the algorithm.

Questions Asked (1)

Q1

Given two singly linked lists, find the node where they intersect and return it. If no intersection exists, return null. The lists must remain unmodified. Implement in C++ and be ready to discuss raw pointers versus shared_ptr and the optimal time/space complexity.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I knew the two-pointer trick going in.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and constraints, then propose an optimal two-pointer solution that aligns the lists by length difference and traverses to find the intersection. Implement in C++ using raw pointers, and discuss trade-offs with shared_ptr and complexity.

Pro tip: Emphasize that the lists must remain unmodified, so avoid tricks like reversing or marking nodes; instead, use length difference or cycle detection. Also, mention that shared_ptr is unsuitable due to ownership semantics and overhead.

1. Clarify the problem

Ask if the lists are singly linked, if they intersect by node reference (not value), and if modification is allowed. Confirm that intersection means sharing the same node, not just same value.

2. Propose an optimal approach

Explain the two-pointer technique: compute lengths, advance the longer list's pointer by the difference, then move both pointers until they meet or reach null. This gives O(m+n) time and O(1) space.

3. Implement in C++

Write clean code using raw pointers (Node*). Handle edge cases: empty lists, no intersection, intersection at head. Avoid modifying the lists.

4. Discuss trade-offs

Compare raw pointers vs shared_ptr: raw pointers are lightweight and standard for such algorithms, while shared_ptr adds overhead and ownership complexity. Mention that shared_ptr could be used if the lists are managed by shared ownership, but it's not ideal for this problem.

5. Analyze complexity and test

State time O(m+n) and space O(1). Walk through test cases: no intersection, intersection at different positions, one list empty.

Key Points to Mention

  • Two-pointer technique with length difference achieves O(m+n) time and O(1) space.
  • Raw pointers are preferred for algorithmic problems due to performance and simplicity; shared_ptr introduces overhead and ownership semantics that complicate the solution.
  • The lists must remain unmodified, so avoid reversing or marking nodes.
  • Intersection is by node reference, not by value.
  • Edge cases: empty lists, no intersection, intersection at head or tail.
  • Alternative approach: use hash set to store nodes of one list, but that requires O(n) space.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.