14. Gas Station || 2 Approach explained || Return Starting Index|| Top 150+ DSA Leetcode Coding JAVA

Описание к видео 14. Gas Station || 2 Approach explained || Return Starting Index|| Top 150+ DSA Leetcode Coding JAVA

In this question, There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].

You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations.

Given two integer arrays gas and cost, return the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return -1. If there exists a solution, it is guaranteed to be unique

We have covered 2 approach, one brute force O(n^2), i.e. nested for loop, iterating each and every combination, 2nd O(n) is using one for loop, calculating sum += gas[i] - cost[i], if sum become negative at some index, then update starting index as pos+1;

We have started the most important part to crack Top Product Based Company i.e. Top DSA Coding Questions. We will cover all questions and patterns in Details. All topics are covered, check the List mentioned below.

What you'll learn
- Learn, implement, and use different Data Structures
- Logic Building
- Problem Solving
- All DSA Concepts

Checkout the Leetcode link in below list, and try to solve.

Top 150 DSA Coding Questions List with Leetcode Links:
https://drive.google.com/file/d/1Nfq9...

Join our Telegram Community:
Telegram channel: https://t.me/itsruntym
Connect with us on Instagram :   / itsruntym  


#coding #software #softwaredeveloper #job #faang #google #amazon #development #developer #career #itjob #programming #leetcode #codingquestions #googleinterview #microsoftinterview #softwareengineer #amazonjobs #softwaredevelopment #problemsolving #leetcodequestion #interview #array #codingchallenge #startcoding #java #javaquestions #basiccoding #beginners #dsa #datastructures #algorithms #timecomplexity #dsawithjava #itsruntym #timecomplexity #spacecomplexity #array #leetcode #faang #problemsolving #logicbuilding #array #dsacoding #gasstation #runtym #runtime #run #itsruntime

Комментарии

Информация по комментариям в разработке