Codility's count passing cars in opposite directions in C#
Overflow averted

Performance of your algorithm is optimal since you iterate the input just once in \$O(n)\$ time complexity. There is a way to avoid the checked overflow guard. Noone forces you to use int to perform the arithmetic in the method body.


int carTravelingEast = 0, pairOfPassingCars = 0;



Using uint with a max value of \$4,294,967,295\$ would never overflow, since:


carTravelingEast can never be more than int's max value \$2,147,483,647\$ (because of the length of an array is capped)
the maximum value \$3,147,483,647\$  as the sum of the custom threshold of one billion + int's max value could never exceed uint's max value (and we exit early on reaching one billion)


Code Conventions


Don't use UPPERCASE variable names for constants; use PascalCase instead.
Use white space according to Conventions.


GetNumberOfPassingCars( int[] passingCars ) -> GetNumberOfPassingCars(int[] passingCars)
foreach( var passingCar in passingCars ) -> foreach (var passingCar in passingCars)

Use plural name for a variable that represents multiple objects: pairOfPassingCars -> pairsOfPassingCars.
Use a constant to avoid magic numbers; const uint maxLimit = 1000000000;.
Throw ArgumentNullException when mandatory arguments are null in public methods.




Code Refactored

public static int GetNumberOfPassingCars(int[] passingCars)
{
    if (passingCars == null) throw new ArgumentNullException(nameof(passingCars));

    const int Overflow = -1;
    const int East = 0;
    const int West = 1;
    const uint maxLimit = 1000000000;
    uint carsTravelingEast = 0, pairsOfPassingCars = 0;

    foreach (var passingCar in passingCars)
    {
        if (passingCar == East)
        {
            ++carsTravelingEast;
        }
        else if (passingCar == West)
        { 
            pairsOfPassingCars += carsTravelingEast;
            if (pairsOfPassingCars &gt; maxLimit)
            {
                return Overflow;
            }
        }
    }

    return (int)pairsOfPassingCars;
}