I think she asked many questions related to elevator design which werent needed. She was unnecessary wanting to make system too complicated by asking questions like service lift and all. System design what I see is starting with simplicity and then including complexity. As usual Gaurav sen was too good
Thank God someone else feels this way. I questioned EVERY SINGLE INTERVIEW OF MINE AND STARTED CRYING because i didn't ask half the number of questions. Honestly, this video gave me a headache instead of info.
While I agree with you, please also consider that she is uploading an honest video on her channel. She could have faked to appear smarter, but I like the fact that she presented her true self. Also, bear in mind that many prospective hirers may be observing her, yet she showcased an honest interview.
I came here for couple of reasons: 1. I wanted to see what kind of design pattern could be used here. There was no discussion about any design pattern. 2. Working code: I wanted to see the code implementation, like use of concurrency or some other smart way. With the size of video I thought there will be actual code.
if I see candidate trying to "apply" design pattern, it is a red flag for senior+, but green flag for junior. Always focus on the problem first, those pattern can indeed apply to smaller portion of the problem, but it is not worth mentioning most of the time.
Usually Interviewers are not that helpful as Gaurav was. The SD interviewers I have faced look at their clock and will tell me to wrap stuff quickly every 5 - 10 mins. Things like current weight of lift and max weight limit should be in the block diagram as well which are not that difficult to think of. Overall still I appreciate the content provided. It was truly unique and really made us think
That was Really great Design interview. had few comments... it was a simple design and questions were a bit more... * why do we need 2 hash maps, there is no random value and floors are fixed, can use a vector or array but thats also not required * instead can use 2 priority list, for up and down and a flag for direction, in one direction complete the queue and move on to the other based on the flag and mediator and person will request to append to the priority queue. * its mediator design pattern problem, no need of 3 classes, a mediator will manage the number of lifts and its access * I guess if we keep the class simple and decoupled, it would be good
A lot of the discussion was unnecessary. Also, it is already recommended to write down thoughts which Keerti was not doing. It felt more like a pep talk.
Good work Keerti and Gaurav, Another easy solution , which you might like is Let's consider 3 important entity of this design . -- request notebook -- which will keep all the floor request in a queue for processing further . -- schedular -- most important component , which will take care of all relative business logic of serving requests to elevators . -- elevator - which will be having two priority queue, up and down , current state and direction . Now schedular is keep processing the notebook queue with relative states of elevators and initiating or filling there serving queue.
Some quick thoughts: 1. We can use a boolean array as well for storing which floor to stop at. Though due to less number of floors/lifts, either approach should be fine. 2. There are cons of storing the hashmap of which floors to stop at, in the lift class. Hence it makes sense to store it in a common place, so that all lifts can simultaneously access the shared information and hence the first lift querying for the current floor to open at, thus serving the user as fast as possible. 3. There was a discussion around multiple directions but LEFT and RIGHT don't seem to make sense for a Lift since usually LIFTs move in vertical direction. Good discussion though. Thanks for your videos, Keerti.
One thing we can do is maintain a priority queue inside very Lift Object and on every request we can add the source floor at first and after getting in the lift another req will put in the destination floor in the queue and the lift will move according to the queue.
The first system design interview I watched fully..... Keerti is very particular about the design decisions made.. lol... was fun to watch.... And thanks for taking the interviewee's role this time.
@@KeertiPurswani so honored to get a reply from you…. So much happiness amidst all chaos…. I enjoyed all the sessions with your father…. You are so amazing, awesome, wonderful and nice….. am not a DS or algo guy…but I enjoy your videos… keep up the good work….. I think people are lucky if they are around you or close to you ☺️
Nice content from both system design techies and experts keep going, this brings lot of learning room to public about such simple systems which become complex in their designs 😊👌👌👌
Can we think of this like a locking system where the resources are lifts available and we lock the lift if it is in moving and release the lock on it after completing the trip? Something like a semaphore/re-entrant locks we can think of. We can also use some sort of asynchronous mechanism like a queue to store the requests and and serve them.
@@gkcs Yes we can achieve that by using 2 different messaging queues (or say topics sort of in Kakfa), so that we can maintain 2 different directions. Also the request in queues will have the following entries (CurrentLevel, destLevel) in that we can cluster 2 people's destination and put them in same request And the lock will be released only when al the persons in lift in that trip has been completed. Did u get that ?
@@gkcs locks are a way to ensure when one lift (Say Lift A) is used by someone say b/w 3rd to 5th floor, then when other person wants to go from 6th to 9 th floor at the same time, then we dont end up allocating Lift A to him.
"Proper Naming and testing things" are the two important things that take extra effort and are sometimes difficult in Software Engineering 😅😂😐 Just Awesome collab🔥
It is never clear why you gets rejected in these kind of rounds. System design is always subjective. Plus I feel if an SE/SSE is designing system then what's the need for Architect in the company. You can't expect someone with less experience to design top notch system within 1 hr time limit.
@@nakulkumar4197 Exactly sir, I can totally understand what you said. Also the fact that companies promoting competitive programming for candidates is a very bad thing to do. I mean till when will they make things difficult? Everyday the gap between Software Engineers and Candidates Preparation is widening. There can a candidate who does not know that great Competitive Coding on spot in that interview, but has a great domain knowledge on which the company works for. He can be an ideal candidate who may bring up the company to great heights who knows? This candidate gets rejected. He goes to mass recruitment company and nobody values him there for his skills. Another place there can be a candidate who knows only to solve programming data structures questions. You give him absolutely difficult questions, he will crack them. But he doesn't like any backend or design skills. Wont the company waste tons of money and the productivity drops? I don't know when this will stop. Yes, some companies like Google can follow it, maybe because there isn't too much stress on project completion or deadlines. But for companies which expect candidates to be very productive and familiar with tech and following code standards due to the need of fast development of products, i think they do not need to keep very difficult DSA questions.
@@vrashankraom it's not about not needing dsa it's about how you manage to think when given a tough question and how do you handle it. Do you get stressed out? Or Do you give up easily? Or Do you try hard to think out loud , how do you communicate with the interviewer. How do you think about other edge cases when you have got the solution for few test cases. This round is more for to check how you can think and how better you think and fast you can think I mean the dsa round and cp
@@vrashankraom Many of the interviewers have ego problems. Plus many keep on asking you questions if you are able to solve them. If they ask you 3-4 questions out of which if you are not able to answer any single one or partially made it correct you will be rejected. Like you have to be 100% correct in all situations.
@@KeertiPurswani yeah ... 🤓 and great thing with this video is that its based on lift system which we use in day to day life ... And familiar with scenarios and terms, in case of designing Netflix,Twitter,... Sometimes if some is new, terms goes over the head😂
Doesn't it make more sense to add the request made by the user once inside the lift as a part of a vector of stop destinations which inturn would be a member variable of the lift class, this way we can be assured what lift has to be stopped at what floor
Learning from uh is always of another level ! The way u introspect every lil detail... Was smthng which amazed me n honestly thts 1 of the things I learnt today.... Just superb ❤️❤️
Means so much Vaishnavi. I have honestly always struggled in going into details. It's a very important skill. I am also learning and trying to improve 😇😇❤️❤️
I am new to your channel. I am loving the content. Thanks for making it (y) For above design, I am thinking of some other way which will make it simpler i guess. Obviously, please correct me if I am wrong. In lift class, we can have a hashmap in which key will be floor number and value will be either true/false saying if lift needs to stop on that particular floor or not. Once user will click on up/down, schedular class will take the request and according to state and direction of all lifts, it will populate above hashmap of eligible lifts. And once person will enter the lift, we will populate hashmap of that particular lift only in which user enters. In this way, it will be easy to separate both the kind of requests and schedular role is very clear that whenever up/down request comes, it will decide which lift to serve and update its hashmap accordingly. @Gaurav Sen , your views on it?
Assigning both the elevators (incase they are 2) to the same floor is bad design. Let's say I'm on floor 5 and i press the button. Both the elevators were vacant and weren't serving any requests. So they both come to me. Now when they both are on my floor (floor 5), I will only get on one elevator and at this time somebody else from some other floor also called the elevator, then the second elevator will have to do more work and it will take more time to serve the new request.
If someone asks me this question 8 to 10 years ago then my knowledge will be in different level. Awesome. @keerthi tried to create program. If you have a program, send that link. I am so excited to review.
Always great to see such an amazing discussion from both individually and in collaboration as well. Great work. Just a small doubt and this might be asked already but let me ask again naively whats your final thought on multilevel nested map approach. Cant it be solved by lets say we generate a key like the example you gave like people_country_gender_age_tag and if they key becomes large we can always use a fixed length hashing algorithm and generate a hash of the key and this becomes the key of a hashmap which reduces our hashmap to single level. Is this one of the possible solution or is something other that @Gaurav Sen you can share.
Hi Keerti, Good collab by the way. Just one issue I had while watching the video, There was some sound issue when Gaurav was speaking, so I could not hear much of the starters that you both had while discussing all the scenarios before approaching the problem
Sorry about that Abhinandan. Constantly working on improving the quality of videos. Hope you like the new one I posted today. Please do let me know your feedback!
marvel: avengers is the biggest crossover in history!!! DC: NO!! Justice league is the biggest crossover in history!!! Keerti Purswani: *hold my "hi guys" with a waving hand and smile*
My first basic question would have been what you want this system to be optimised for? Why there are only 3 elevators? Starting with 3 means that someone has already started the design, what's the thought process behind starting with 3. Just abstract?
Requirement Analysis - 1. Will there be multiple lift instances? 2. Will people also mention which floor he/she wants to move while putting a request for a lift or it would be taken cared off after the person gets into the lift? 3. Will a request for a lift be only for a specific lift or any other lift which is idle at that time also be used for the purpose? 4. Some of the possible corner cases - a. Lift moving upward, someone enters, but wants to go to down and pressed the button accordingly and vice-versa. b. List is at last floor and two persons at two different floors want to go to the last floor. c. List is at first floor and two persons at two different floors want to go the basement. 5. What if the lift is overweight? Simple thought - Env with multiple lifts whenever a request comes in for a PARTICULAR direction, one lift would be chosen among all the lifts moving in the same direction and currently in nearest lower floors (for UP) or nearest upper floors (for DOWN) in comparison to the source floor. we an have little more intelligence. In case, nearest one is overweight, then the 2nd nearest one would be chosen. Now, this above scenario is valid for multi-lift instances env. Here since there are multiple lifts, we can further do something like whichever requests can be served early considering the close proximity of any lift with the source floor will be taken cared off, but there must be some threshold of how many times a request can be delayed to avoid any kind of starvation. Env with single lift/each lift has a separate switch. Lift will always process the requests in order. Resource - delegates call to the Service/Manager class, request(src_floor, dest_floor), addLift(Lift), removeLift(Lift) Service - 1. has instance of scheduler and call will be delegated to scheduler-request would be added in the queue, request(src_floor, dest_floor). 2. has instance of a LiftInventory which is the inventory of all lifts - addLift(Lift), removeLift(Lift). Scheduler - 1. queue of requests (each request has id, src_floor, dest_floor), 2. Map with key - direction, value - list of elevators ids moving in the direction (lift ids sorted in ascending order) . 3. allocate(src_floor, dest_floor) - find list of elevators moving in same direction, then search in the list using binary search to find the most suited lift (based on close proximity discussed above considering multiple lifts env). If none of the lifts are moving in that direction, go check if there is any lift which is still idle, this info can be found from the inventory. If none of the lifts are idle, then assign a lift which will complete processing its requests soon. 4. unallocate(Lift) : When a lift completes processing all its requests, it should be removed from map and also updated in LiftInventory class. LiftInventory - Map map, getAllLifts(), getIdleLifts(), allocateLift(Lift), unallocateLift(Lift). Lift - id, state, direction - This can be considered as a state machine - If any lift is moving, its door can't be open/ if the door is open, lift can't move - all these cases would be handled. LiftState - opendoor(), closedoor(), move() - Four subclasses - OpendoorState, CloseDoorState, StandingState, MovingState, UnusedState. Direction - ENUM - UP/DOWN.
@@KeertiPurswani Always Di... Getting interviewed by Gaurav sir is dream come true! May be some day i got a chance....🥺🥺 Even mock interview by u is a dream now😕
2-4 YoE is one of the worst experience ranges to interview coz companies start asking LLD and HLD even though most people don't get to work on distributed systems or getting into the "architecture" of things so early in the career. I think all this should be asked after more than 5 yoe. I mean elevator design's lld might not be that difficult as long as you keep it really simple but if the interviewer decided to deep dive into say the algorithmic part, then BOOM! Game Over. Way too many variations.
But interviewer want us to write classes, functions, composition, usage and the actual logic of any functionality....not only these simple class diagrams
This discussion is amazing , but would like to understand how to remember the discussions till the end and design it according to the discussions because sometimes discussions and designs go in a different directions i.e. discussions go in one direction and design may move in other. So how can we make sure that discussions and design are in sync with each others 😊 it will be really great if you could give us some insights on the same..!!
I think the interview was unnecessarily complicated due to the exhaustive requirements and discussions. I was told by an interviewer that we do not want to make an actual system, but just test you on how you'd build a small tiny version of it. Moreover, the output of 1 hour is just one class(?) diagram which would be a little insufficient? No offence meant. Just penning down my thoughts.
Yup, they do ask such questions but expectation isn't that you will be able to go in detail and do everything but atleast basic requirements and basic idea should be there😊
Thank you, ma'am, this is very insightful. You are explaining to us every thought we should speak up and how to go in a particular direction and I think that's the best way we always wanted to learn! Thanks to Gaurav Sir as well!
Plz make a detailed video on how freshers can get international placements in top companies( of US,UK, Canada, Singapore etc) .Detailed video specially fr fresher (2020passout) N also fr experienced people.
I cannot watch this videos. You're damm cute while giving interview, I just keep losing my focus 😅 that subtle voice and face while asking doubt ..... is too much
Funny, you started with System class having too many responsibilities, so created another class named Schedular . But then removed System class, again left with 1 class with all the responsibility. Doesn't follow responsibility principle yet