rrylee
4/20/2016 - 12:59 PM

## 红路灯撞车

``````function crossroads(road1, road2, crossTime) {
var j = 0;
for (var i = 0; i < road1.length; i++) {
return true;
}
j++;
}
return true;
}
}
return false;
}``````

Consider an Uber-City where the only passenger vehicles on the roads are self-driving Uber cars. Since all the cars are self-driving, you could synchronize the car speeds in such a way that traffic lights would be obsolete.

As a first step you need to implement an algorithm that would check whether removing traffic lights at a given intersection of two one-way roads will lead to a car crash.

For each road you know when a car will approach the crossroads. You also know how long it takes to cross the crossroads.

Example

``````For road1 = [1, 5, 6, 7], road2 = [3, 10] and crossTime = 2, the output should be
``````

``````For road1 = [2], road2 = [3] and crossTime = 2, the output should be
``````

The car on the first road will not make it when the car from the second road appears since crossing the intersection takes 4 seconds.

``````[input] array.integer road1

A strictly increasing array of positive integers which define the times (in seconds) when a new car approaches the crossroads by the first road.