Bridge Car Weight Problem

Problem Overview

  • Find the minimum number of drivers who must turn back so the bridge's weight limit is never exceeded.
  • Input: U (bridge weight limit) and weight[] (car weights in order); Output: the minimum count of turn-backs.
  • Rules: at most two cars on the bridge; cars enter/exit in queue order; any driver who turns back leaves the line permanently.
  • Real-world context: managing traffic on a one-way bridge under weight constraints.
  • This coding interview question is a Github interviews problem and a classic interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: