Passing Cars
Problem statement
Each value in directions describes a car's travel direction along a two-way road: 1 travels east and 0 travels west. Return the number of pairs (i,j) with i < j, directions[i] == 1, and directions[j] == 0.
Function
countPassingCars(directions: int[]) → longExamples
Example 1
directions = [1,0,1,0,0,1]return = 5The first eastbound car passes three westbound cars and the second passes two.
Constraints
0 <= directions.length <= 2 * 10^5.- Every value is 0 or 1.