Company: HashedIn
Difficulty: medium
Vehicle Collisions on Highway Imagine there are n vehicles positioned uniquely along an endless highway, numbered consecutively from 0 to n-1 going from left to right. You have a string called traffic of length n , where each character represents the behavior of a vehicle: \'L\' means the car is traveling leftward \'R\' means it\'s traveling rightward \'S\' signifies it\'s stationary All cars in motion travel at the same speed. Collision Rules: When vehicles traveling in opposite directions meet, they crash, adding 2 to the total count of collisions. A moving vehicle crashing into a stationary vehicle adds 1 to the collision count. Upon crashing, all involved vehicles stop moving permanently. Vehicles do not alter their course or movement state unless involved in a collision. Input Format A string S representing the directions of cars on a road. Output Format Return an integer that represents the total number of impacts or collisions that will occur between cars as they move according