Given N frogs on a number line, each starting at position S[i] and ending at position F[i], calculate the total number of collisions that occur when they jump at a speed of 7 units per second.
Example 1:
Input:5
2 8
1 4
3 9
4 6
5 7
Output:1
Example 2:
Input:3
9
4
6
10
Output:0
Constraints:
1 <= N <= 10^5
1 <= S[i], F[i] <= 10^9
S[i] <= F[i]
solution.cpp
Loading...
Run code to see test results
00:00 / 69:42
Frog Collision Problem
MediumMed•151 views
Given N frogs on a number line, each starting at position S[i] and ending at position F[i], calculate the total number of collisions that occur when they jump at a speed of 7 units per second.