write the code
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
write the code
![Given two integer arrays A and B of size N.
There are N gas stations along a circular route, where the amount of gas at
station i is A[i].
You have a car with an unlimited gas tank and it costs B[i] of gas to travel from
station i
to its next station (i+1). You begin the journey with an empty tank at one of the
gas stations.
Return the minimum starting gas station's index if you can travel around the
circuit once, otherwise return -1.
You can only travel in one direction. i to i+1, i+2, ... n-1, 0, 1, 2. Completing the
circuit means starting at i and
ending up at i again.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F487a6116-8060-4ffe-bf72-58129cec9b2d%2F98951796-f5df-4546-bd36-d4451054bb98%2Fhoedqx8_processed.jpeg&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









