Navigate maze via HTTP API
Company: Ramp
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates a candidate's ability to implement programmatic traversal of linked resources via an HTTP API, testing skills in network I/O, control flow, state management, and algorithmic traversal.
Constraints
- 1 <= len(links) <= 100000
- Each key in links is a unique URL string
- Each value in links is either another URL (a key in links) or a terminal 'END:<result>' string
- start is a non-empty string
- If a cycle is encountered, return 'LOOP'
- If a non-terminal response refers to a URL not present in links (including start not present), return 'INVALID'
Examples
Input:
Expected Output: success
Input:
Expected Output: LOOP
Hints
- Model the navigation as following edges in a directed graph where each node has at most one outgoing edge.
- Use a visited set to detect if a URL is revisited (cycle).
- Check for terminal responses with a prefix test on 'END:'.
- If a next URL is not found in the mapping, return 'INVALID'.