PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Decide reachability with buses and limited walking

Last updated: Apr 26, 2026

Quick Overview

This question evaluates the ability to combine graph reachability with geometric distance constraints, testing competencies in graph algorithms, Manhattan-distance reasoning, and constrained-path modeling within the Coding & Algorithms domain.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Decide reachability with buses and limited walking

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

You are given: ( 1) a start point (xs, ys), ( 2) an end point (xe, ye), ( 3) an integer K, and ( 4) an undirected graph of bus stations where each node has integer coordinates (xi, yi) and edges indicate bidirectional bus routes. Walking uses Manhattan distance d((x1, y 1), (x2, y 2)) = |x1 − x2| + |y1 − y2|. Riding a bus along any sequence of connected stations costs zero walking distance. You may: (a) walk from the start to any station (s), ride buses across the graph, then walk from some station to the end; or (b) walk directly from start to end. Determine whether there exists a strategy whose total walking distance is ≤ K. Design an algorithm, state and justify its correctness, analyze time/space complexity, and implement a function returning true/false.

Quick Answer: This question evaluates the ability to combine graph reachability with geometric distance constraints, testing competencies in graph algorithms, Manhattan-distance reasoning, and constrained-path modeling within the Coding & Algorithms domain.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
  • Find the Most Common Visit Pattern - Amazon (hard)
  • Maximize Value Under a Budget - Amazon (medium)
Amazon logo
Amazon
Jul 31, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
2
0

You are given: (

  1. a start point (xs, ys), (
  2. an end point (xe, ye), (
  3. an integer K, and (
  4. an undirected graph of bus stations where each node has integer coordinates (xi, yi) and edges indicate bidirectional bus routes. Walking uses Manhattan distance d((x1, y 1), (x2, y 2)) = |x1 − x2| + |y1 − y2|. Riding a bus along any sequence of connected stations costs zero walking distance. You may: (a) walk from the start to any station (s), ride buses across the graph, then walk from some station to the end; or (b) walk directly from start to end. Determine whether there exists a strategy whose total walking distance is ≤ K. Design an algorithm, state and justify its correctness, analyze time/space complexity, and implement a function returning true/false.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.