Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose there is a circle. There are n petrol pumps on that circle. You are given two sets of data. 1. The amount of petrol

Suppose there is a circle. There are n petrol pumps on that circle. You are given two sets of data. 1. The amount of petrol that every petrol pump has. 2. Distance from that petrol pump to the next petrol pump. Calculate the first point from where a truck will be able to complete the circle (The truck will stop at each petrol pump and it has infinite capacity). Expected time complexity is O(n). Assume for 1 liter petrol, the truck can go 1 unit of distance. For example, let there be 4 petrol pumps with amount of petrol and distance to next petrol pump value pairs as {4, 6}, {6, 5}, {7, 3} and {4, 5}. The first point from where truck can make a circular tour is 2nd petrol pump. Output should be “start = 1” (index of 2nd petrol pump).

Step by Step Solution

3.42 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

SECODE creating a class for Queue class Queue def initself selfqueue def putself ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Mathematics questions