Тёмный

Car Pooling | Leetcode  

Techdose
Подписаться 174 тыс.
Просмотров 11 тыс.
50% 1

This video explains a very important simulation based programming interview problem which is the car pooling problem from leetcode 1094. In this video, I have first explained the problem statement using simple examples and then explained the observation and intuition. Finally, I have given the dry run of the idea along with code implementation.
CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
======================================PLEASE DONATE=============================
🧡 SUPPORT OUR WORK: / techdose
💚 UPI-ID: surya.kahar@ybl
💞JOIN Membership: / @techdose4u
==============================================================================
INSTAGRAM : / surya.pratap.k
LinkedIn: / surya-pratap-kahar-47b...
WEBSITE: techdose.co.in/
TELEGRAM Channel LINK: t.me/codewithT...
=======================================================================
USEFUL LINKS:
🟠Must do TIPS to ACE Virtual Interview: • 🔴Must do Tips to ACE y...
🟢Best strategy to excel your coding interview: • 🔴Best strategy to exce...
🟡Get your dream job in 1 month: • 🔴Get your dream job in...
🔵How to crack dream job in just 2 months: • How to crack dream job...
🟣7 Days DSA plan: techdose.co.in...
RELATED LINKS:
CODE LINK: gist.github.co...

Опубликовано:

 

8 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 25   
@LeagueOfChallenger
@LeagueOfChallenger 2 года назад
Congrats on reaching 100k subscribers!
@techdose4u
@techdose4u 2 года назад
Thanks 😊
@TomJerryFilm
@TomJerryFilm 2 года назад
Tech Dose provides the best videos for computer science👍🏾👍🏾👍🏾, may I know what software and pen tablet you use for the videos?
@arvindrawat3641
@arvindrawat3641 2 года назад
did this ques 3 days ago. great explanation
@techdose4u
@techdose4u 2 года назад
Thanks :)
@pranavsharma7479
@pranavsharma7479 2 года назад
You back wow
@supratimbhattacharjee5324
@supratimbhattacharjee5324 2 года назад
//It can also be done using hashing class Solution { public: bool carPooling(vector& trips, int capacity) { map netPas; for(auto x: trips) { netPas[x[1]]+=x[0]; netPas[x[2]]-=x[0]; } for(auto x: netPas) { capacity-=x.second; if(capacity
@mk-mc8yx
@mk-mc8yx 2 года назад
Thankyou. Before I saw your solution, I came up with my approach. But your approach looks simple. Can you have a look at my soln, appreciate any feedback. What I am a basically doing is construct two sets of nodes which are startJourney and endJourney nodes. And an array of all bus stops. Iterate through all bus stops and at each bus stop process any start/end Journey nodes. Only downside with my approach is I guess it is quadratic time complexity ? I know thats bad, but just wanted to share my first attempt approach.
@mk-mc8yx
@mk-mc8yx 2 года назад
Here is it: feedback appreciated. //insert relevant headers using namespace std; typedef struct Trip { int numPassengers; int pickLoc; int dropLoc; } Trip ; int processStartNodes(int loc, const unordered_multimap &sNode, int capacity) { auto range = sNode.equal_range(loc); for_each (range.first, range.second, [&capacity](const unordered_multimap::value_type &x){ cout
@techworld3043
@techworld3043 2 года назад
Love the video bro, thanks . what software are you using to type ?
@shubhamhembram9144
@shubhamhembram9144 Год назад
Sir, can you explain the marathon race problem where the runner has to pick required number of water bottles to survive and complete the race. He also has some water bottles initially but are not enought to complete the race. so he has to stop mininum to times to complete the race?
@patigesuhas
@patigesuhas 2 года назад
Wouldn't it easier if we just used hashmap, and entering indices are added and leaving indices are substracted?
@rajankhunt7002
@rajankhunt7002 2 года назад
Optimum location of point to minimize total distance [OR] Rasta and Kheshtak in SEARCH AND SORT if you make on video plz, plz, plz,
@sayantaniguha8519
@sayantaniguha8519 2 года назад
Aj Q ni aya telegram mein So, should we consider this a part of 28-Days Arrays ?
@techdose4u
@techdose4u 2 года назад
Person in charge is sick :) Will resume once he recovers :)
@Mukesh-nx8tf
@Mukesh-nx8tf 2 года назад
what app do you use to record screen and for white board?
@sarthaksarthak6912
@sarthaksarthak6912 2 года назад
O(n) class Solution { public: bool carPooling(vector& trips, int capacity) { int start[1001]={0}; for(int i=0;i
@mayukhchatterjee4863
@mayukhchatterjee4863 2 года назад
Hello Tech Dose...I have a question how did you get Mtech in Jadavpur University? Was it through Gate score? Can you please explain me the application procedure.
@techdose4u
@techdose4u 2 года назад
Yes GATE score
@mayukhchatterjee4863
@mayukhchatterjee4863 2 года назад
Can you tell me the usual Gate cut off score for cse in JU?
@nivash8024
@nivash8024 2 года назад
Explain leetcode 996 sir
@coder1015
@coder1015 2 года назад
cost for joining the dsa course ??
@priyankabahety895
@priyankabahety895 2 года назад
Can you please provide java code for this approach.
@ravindrakawale1014
@ravindrakawale1014 2 года назад
This is my solution of O(n) complexity - class Program { static void Main(string[] args) { int[,] trip = new int[,] { { 3, 0, 7 }, { 1, 4, 7 }, { 4, 7, 10 } }; int carVacantSit = GetCarVacancy(trip); if(carVacantSit > 0) Console.WriteLine("Car Vacent seats - " + carVacantSit); else Console.WriteLine("Car is full"); } public static int GetCarVacancy(int[,] trip) { int carCapacity = 5; int carCurrentPassenger = 0; int drop = 0; Dictionary dropingPassenger = new Dictionary(); for(int i=0; i < trip.Length / 3; i++) { drop = trip[i, 1]; if(dropingPassenger.Count == 0) { dropingPassenger.Add(trip[i, 2], trip[i, 0]); carCurrentPassenger += trip[i,0]; } else { if (dropingPassenger.ContainsKey(drop)) { carCurrentPassenger -= dropingPassenger[drop]; } if(dropingPassenger.ContainsKey(trip[i, 2])) { dropingPassenger[trip[i, 2]] += trip[i, 0]; carCurrentPassenger += trip[i, 0]; } else { dropingPassenger.Add(trip[i, 2], trip[i, 0]); carCurrentPassenger += trip[i, 0]; } } } return carCapacity - carCurrentPassenger; } }
Далее
Car Pooling - Leetcode 1094 - Python
14:45
Просмотров 25 тыс.
Trapping Rainwater Problem | Leetcode #42
34:12
Просмотров 97 тыс.
Сказала дочке НЕТ!
00:24
Просмотров 1,1 млн
Harder Than It Seems? 5 Minute Timer in C++
20:10
Просмотров 169 тыс.
Why More People Dont Use Linux
18:51
Просмотров 182 тыс.
All Rust string types explained
22:13
Просмотров 168 тыс.
I've been using Redis wrong this whole time...
20:53
Просмотров 356 тыс.