← PayPal Interview Insights

PayPal·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

PayPal SWE interview with a graph/traversal problem dressed up in a fun theme. The core challenge was solid even if the wrapping was a bit whimsical.

Questions Asked (1)

Q1

You're given a castle where rooms are named after flowers. Each room contains an instruction pointing to the next room. Write an algorithm to find all rooms that contain treasure.

Algorithms & Data Structures
Author's notes

The flower-naming thing threw me for a second, felt like a trick.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the castle as a directed graph where each room is a node and each instruction is a directed edge. Then, traverse the graph to find all rooms containing treasure, handling cycles and ensuring all reachable rooms are visited.

Pro tip: Clarify with the interviewer whether the graph is guaranteed to be connected and whether there can be multiple treasure rooms. Also, discuss the trade-offs between BFS and DFS, and mention that cycle detection is crucial to avoid infinite loops.

1. Clarify the problem

Ask questions to understand the input format, whether the graph is directed, if there are cycles, and how treasure is indicated. Confirm if all rooms are reachable from a starting room.

2. Choose data structures

Represent the castle as an adjacency list or matrix. Use a set or boolean array to track visited rooms and a list to collect treasure rooms.

3. Select traversal algorithm

Use BFS or DFS to traverse the graph from the starting room, marking visited nodes and checking for treasure. Handle cycles by not revisiting nodes.

4. Implement and test

Write pseudocode or code, then walk through examples including edge cases like cycles, disconnected components, and no treasure.

5. Analyze complexity

State time and space complexity: O(V+E) for traversal, O(V) for visited set and output.

Key Points to Mention

  • Graph representation: adjacency list vs. adjacency matrix
  • Cycle detection to avoid infinite loops
  • BFS vs. DFS trade-offs (e.g., memory, shortest path)
  • Handling disconnected components if not all rooms are reachable
  • Time and space complexity analysis
  • Edge cases: empty castle, single room, multiple treasures

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