FastPrepRetryable URL Maze
Problems/Retryable URL Maze

Retryable URL Maze

Ramp logoRamp● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report establishes the task identity and central capability. This practice contract supplies only the portable interface, deterministic boundary rules, and output serialization needed for consistent execution.

Model a URL maze with deterministic per-endpoint response sequences. Each row in responses is [url, attempt1, attempt2, ...]. An attempt is:

  • 503 or MALFORMED: failed attempt;
  • NEXT:a,b,...: successful response listing next URLs;
  • CONGRATS: terminal success.

Starting at start, perform BFS with visited de-duplication. When a URL is dequeued, consume at most maxRetries + 1 attempts, stopping at its first valid NEXT or CONGRATS. An exhausted URL adds no neighbors.

Return the first BFS path from start to a URL that yields CONGRATS. Preserve NEXT order for ties. Return an empty array when no success is reachable.

Function

solveUrlMaze(start: String, responses: String[][], maxRetries: int) → String[]

Examples

Example 1

start = "start"responses = [["start","503","NEXT:a,b"],["a","NEXT:c"],["b","CONGRATS"],["c","CONGRATS"]]maxRetries = 1return = ["start","b"]

The start succeeds on its retry; BFS reaches b before the deeper c path.

Example 2

start = "start"responses = [["start","503","503"],["a","CONGRATS"]]maxRetries = 1return = []

The start exhausts its two allowed attempts and exposes no neighbor.

Constraints

  • 1 <= responses.length <= 10^4.
  • Every URL appears as the first field of at most one row.
  • 0 <= maxRetries <= 20.

More Ramp problems

  • Accept or Decline QueriesOA · Seen Sep 2026
  • Detect Recurring Transactions with Tunable TolerancesONSITE INTERVIEW · Seen Jul 2026
  • Recipe Management SystemOA · Seen Mar 2026
All Ramp interview questionsSee Ramp hiring insights
Saved
public String[] solveUrlMaze(String start, String[][] responses, int maxRetries) {
  // write your code here
}
Checking account…