Katkat

Find exit URL via BFS API calls

RampSoftware Engineer · Technical Screen

Last updated

This question evaluates graph traversal and resilience when interacting with HTTP APIs, covering BFS/DFS reasoning, cycle detection to avoid infinite loops, retry handling for transient HTTP 500 responses, and timeout management for slow pages.

Question

Design and implement a function that, given a starting URL "/", performs BFS or DFS by repeatedly sending HTTP GET requests of the form GET "example.com/<path>". Each response is a JSON object either of the shape { next_step: ["...", "..."] } or the string "Congrats" when the exit page is reached. Return the exit path (e.g., "jkdf"). Your solution must (

  1. avoid infinite loops when cycles occur, (
  2. gracefully retry when a request returns HTTP 500, and (
  3. impose a timeout for slow pages while still guaranteeing eventual completion if a path exists.