Company: Deutsche_Graduate_Analyst__IITK
Difficulty: medium
Bridge Weight Limit Problem Description There is a small, one-way bridge that can carry a maximum weight of U units at a time. There is also a line of N cars waiting to cross the bridge. The weights of the cars are given as an array weight (for K within the range [0...N-1]). The car that will enter the bridge first weighs weight[0] , the car that will enter second weighs weight[1] , and so on. At most two cars can be on the bridge at the same time. To begin, the first two cars in line will enter the bridge. Then the third car will enter the bridge as soon as the first car leaves the bridge, the fourth car will enter when the second car leaves, and so on. The cars leave the bridge in the same order they entered it. However, this may lead to a situation where cars exceed the bridge's weight limit. To prevent such a situation, some drivers have to turn back. When a driver turns back, all drivers behind them in line move one position closer to the bridge. The driver who turns back is remov