'Coding has over 700 languages', '67% of programming jobs aren’t in the technology industry', 'Coding is behind almost everything that is powered by electricity'
Topics

# Water Droplet Mixing

Easy
0/40
Average time to solve is 28m
Contributed by
2 upvotes
Asked in companies

## Problem statement

Consider a pipe of length L. The pipe has N water droplets at N different positions within it. Each water droplet is moving towards the end of the pipe (x = L) at different speeds. When a water droplet mixes with another water droplet, it assumes the speed of the water droplet it is mixing with, or to put it in other words, the water resulting water droplet formed post mixing will take the speed of the smaller ones.

Determine the number of droplets that come out of the pipe.

Detailed explanation ( Input/output format, Notes, Images )
Constraints :
``````1 <= t <= 100
0 <= N <= 10^5
1 <= L <= 10^9
0 <= Position[i] <= L
1 <= Speed[i] <= 10^9

Time Limit: 1 sec
``````
Sample Input 1 :
``````1
5 12
10 8 0 5 3
2 4 1 1 3
``````
Sample Output 1 :
``````3
``````
Sample Input 2 :
``````1
2 5
0 1
1 1
``````
Sample Output 2 :
``````2
``````
Console