← Walmart Interview Insights

Walmart·Software Engineer·Technical Phone Screen·Junior

JuniorPending
May 2026Remote

Summary

Somehow passed a phone screen despite getting 3 out of 5 technical questions wrong, and now there's a Python coding round with the hiring manager coming up. The whole thing feels like a mistake on the company's part, and the poster is half-looking for someone to tell them it's okay to bail.

Questions Asked (1)

Q1

How would you recursively reverse a linked list?

Algorithms & Data Structures
Author's notes

Mind went completely blank.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining the recursive function's contract: given a head node, return the new head of the reversed list. Then walk through the base case and the recursive step, emphasizing how the current node's next pointer is updated after the recursive call returns. Finally, discuss time and space complexity, and mention iterative alternatives for comparison.

Pro tip: Explicitly state that recursion uses O(n) stack space, which can cause stack overflow for large lists—showing awareness of production constraints at a company like Walmart, where scalability matters. Also, offer to write the code iteratively to avoid this, demonstrating versatility.

1. Clarify the problem and constraints

Confirm assumptions: singly linked list, reverse in-place, return new head. Ask about edge cases like empty list or single node.

2. Define the recursive function

State the function signature: reverse(head) returns the new head. Explain that it processes the rest of the list first, then adjusts pointers.

3. Explain base case and recursive step

Base case: if head is null or head.next is null, return head. Recursive step: recursively reverse the rest, then set head.next.next = head and head.next = null.

4. Trace through an example

Walk through a small list (e.g., 1->2->3) to show how pointers change and the new head is returned up the call stack.

5. Analyze complexity and alternatives

State O(n) time and O(n) space due to recursion stack. Mention iterative approach for O(1) space and discuss trade-offs.

Key Points to Mention

  • Base case: empty list or single node returns head as is.
  • Recursive call returns the new head of the reversed sublist.
  • Pointer manipulation: head.next.next = head; head.next = null.
  • Time complexity O(n), space complexity O(n) due to call stack.
  • Potential stack overflow for large lists; iterative solution uses O(1) space.
  • Edge cases: empty list, single node, and ensuring no cycles are introduced.

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