FastPrepMinimum Bridge Turnbacks
Problems/Minimum Bridge Turnbacks

Minimum Bridge Turnbacks

BNSF Railway logoBNSF Railway● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamples

Problem statement

Source note: The original report gives the bridge rules, the function signature and a sample crossing, but no limits on the input numbers. Our version is about 99% the same as the reported question.

A line of cars approaches a one-way bridge in the order given by the integer array weight. The bridge supports at most a total weight of U, and at most two cars can be on it at the same time.

Cars enter and leave in their original relative order. Before a car enters, its driver may be told to turn back. That car is then removed permanently, while every remaining car keeps its relative position.

Choose which drivers turn back so that the bridge is never overloaded. Equivalently, every retained car must weigh at most U, and every two consecutive retained cars must have a combined weight of at most U.

Return the minimum number of drivers who must turn back.

Function

solution(U: int, weight: int[]) → int

Examples

Example 1

U = 9weight = [5,3,8,1,8,7,7,6]return = 4

One optimal choice keeps the cars with weights [5,3,1,6]. Its consecutive sums are 8, 4, and 7, all at most 9. Four drivers turn back.

More BNSF Railway interview questions

  • LRU CachePHONE SCREEN · Seen Nov 2026
  • Minimum Station Tracks for a Train ScheduleONSITE INTERVIEW · Seen Nov 2026
  • Two SumPHONE SCREEN · Seen Nov 2026
  • Maximize Valid TrainsONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Maximum Profit from an Increasing Price TripletOdoo · OAOdoo interview questions
  • Minimum Sorted Erasure OperationsAtlassian · OAAtlassian interview questions
  • Longest Increasing Subsequence With Bounded Adjacent DifferenceGoogle · PHONE SCREENGoogle interview questions
  • Longest Increasing Subsequence With Bounded Adjacent DifferenceAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Card Game: Best First-Player ScoreShopify · OAShopify interview questions
  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA

BNSF Railway interview experiences

  • BNSF Railway SWE Phone Screen, Level Not Reported: 1 Experience
  • BNSF Railway Experienced SWE Interviews: 2 Experiences
All BNSF Railway interview questionsSee BNSF Railway hiring insights
Saved
class Solution {
    public int solution(int U, int[] weight) {
        // Write your code here.
    }
}
Checking account…