i have a problem, i need some explanation for how to fix it, can i get some help please ?
there are n particles numbered from 0 to n-1 lined up from smallest to largest ID along the x-axis.
the particles are all released simultaneously. once released, each particle travels indefinitely in a straight line along the positive x-axis at a speed.
when two particles collide, the faster particle moves through the slower particles and they both continue moving without changing speed or direction.
write a function that return the number of collision occurring with particle pos.
collision has the following parameters:
speed[speed … speed[n-1]]: an array of speed* indication speed of particle i.
pos: index of the particle for which to count collisions.
- 1 <= n <= 100000
- 1 <= speed* <= 1000000000
- 0 <= pos< n
the particle at pos = 2 will collide with particle 0 and 1 as they pass it from behind.