Water Droplet Mixing

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 rates.

When a water droplet mixes with another water droplet, it assumes the speed of the water droplet it is mixing with. Determine the no of droplets that come out of the end of the pipe.

 

CodingNinjas
author
2y
  • I gave him a brute force type approach by starting from the second drop and comparing it with the previous one and after checking the condition of speed and time if they can mix or not. Similarly, thi...read more
CodingNinjas
author
2y

CN hint:

A drop will mix with another drop if two conditions are met:

- If the drop is faster than the drop it is mixing with

- If the position of the faster drop is behind the slower drop. Also more ...read more

CodingNinjas
author
2y
Minimum Position Approach

We can solve this problem by calculating the time required by each drop to reach the end of the pipe and comparing them based on their position in the pipe and the time requir...read more

Add answer anonymously...
SPRINKLR Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter