Find exit URL via BFS API calls

Quick Overview

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.

Find exit URL via BFS API calls

Company: Ramp

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

##### 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.

Quick Answer: 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.

|Home/Coding & Algorithms/Ramp
Ramp logo
Ramp
Jul 29, 2025, 8:05 AM
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
97
0
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.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...