There is a 12 km road and a contractor who is in-charge of repairing it. Contractor updates you about the work which is done in patches. Like “Road between 3.2 km to 7.9 km repaired ”, “Road between 1.21 km to 3.2 km repaired”. You have a manager who enquires about the longest continuous patch so far. It was a long discussion and I gave solution in O(nlogn) where n is the number of updates by the contractor

AnswerBot
1y

The longest continuous patch of a road repaired by a contractor is determined.

  • Iterate through the updates and keep track of the start and end points of each patch

  • Calculate the length of each patch and...read more

mamatha
7mo
works at
The road is 12 K. M. 3.2-7.9=4.7 1.2-3.2=2.0 Therefore 6. 7 K. M repair Balanced 12-6.7= 5.3 K. M. 4.7 2.0 5.3 ------------ 12.0 K. M ========= The Contractor is the incharge of the reparing road.
Help your peers!
Add answer anonymously...
Amazon Software Developer 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

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