Live Mock DSA | GeeksforGeeks

GeeksforGeeks · Intermediate ·📰 AI News & Updates ·3y ago

Key Takeaways

Conducts a live mock interview for data structures and algorithms

Full Transcript

[Music] [Music] so [Music] hi everyone welcome back to geeksforgeeks today we have another dsa mock interview but before we start this mock interview let me give you a quick introduction about myself so my name is yashdi vedi currently i'm working as a dsa mentor at geeksforgeeks i'm also a candidate master on court forces and a five star on court chef so today we'll be interviewing cervesh who is from iit and we will i'll be asking him two or three dsa questions in a span of one hour so all of you can quickly just give me a plus one in the chat if my voice is clearly audible and the like everything is working fine so that we can start on time and uh since we have just give us a thumbs up to the video and hit the like button so that i can understand that okay everything is working fine and i'll invite the guests for today so uh great so let me invite service to the stream uh hi service can you please introduce yourself to the audience so my complete name is mukund i am from mumbai maharashtra and i am currently in the final year from iit bhuranasi my major is in chemical engineering i have programming since my second year and i am a specialist on code forces and a guardian on lead code so uh my most projects are in web development and coming to my certain interests the most they are playing badminton or learning or reading about history so that is my introduction okay so uh since you said that your major interest is in web development so can you tell us a little bit about any of your projects the the best projects that you have made so the one project that i have mentioned in my resume is a one stack application it is basically a chat application which lets you chat with your friends or a single chat or create group chats in the group chat you can add or delete a user you can update either your data or if your admin you can remove somebody so yeah basically every crowd of crowd operations is applied and you have a facility of making groups and other things in it as well yes yes yes okay uh so as you know like first of all are you excited for this mock interview or you're nervous yes i'm excited okay so how much you rate yourself uh on a scale of 10 in dsa i think 7.5 okay so as you know today i'll be interviewing you and the interview will last for 45 minutes to one hour depends on how quickly you solve the problems i'll be asking you uh two problems the second problem will have a follow-up problem if you are able to solve the second problem within time and if you are able to solve the second problem along with the follow-up then i can ask you a third question as well depending on the time so all of all the audience everyone in the audience can give us a thumbs up to the video and give us a plus one so that we can start so service down there in the screen you will see that you have a share option so can you please share your screen you will see there is a share option so is the screen you will get an option uh yeah let me add it yeah now it is visible perfect so i'll give you i'll give you a question in the private chat so just quickly open the private chat and you will see that there's a question right great so you can open it now and the audience can also start solving it uh side by side so let's start off with this question okay so let's uh quickly see this question first of all so the like uh have you ever played first of all have you ever played snake and ladder game in your childhood yes okay so this question uh in this question what i'll give you is i'll give you a chess board like i'll give you a snake snake and ladder board and that will be of dimension 5 cross 6 okay so basically that means there will be 30 cells in the chessboard is this part clear 30 cells will be there in the chessboard starting from 1 to 30. so it's a one based chessboard one based index chessboard and the dimension is 5 6 it will have 30 uh cells what you have to do is you have to find the minimum number of dice throws okay like you know that we have we throw a dice and whatever number comes on the dice according to that we take steps right so you have to tell in this question you will be starting from the very first cell that is the cell number one like cell with the index value as one you'll be starting from there and you have to find the minimum number of dice throws uh in which you can reach the destination or you can basically the destination is nothing but the last cell of the boat correct that is nothing but the uh cell 30 cell with the value is 30 right you can scroll down uh to see that right you can see that the cell with 30 value uh you can scroll up now on you can see the diagram there so you can see that 30 like you will be starting from one and you will have to pass the hurdles and stuff and you have to get uh in the minimum number of dice throws you have to reach 30 okay that is the thing now in a like it's not a normal board right it's not a normal five cross six volt uh like what's the difference here the difference is that you have snakes and you have ladders as well so what will happen when you encounter snakes when you encounter a snake at the let's say uh you throw a die and you reach a particular cell let's say if i'll i see this diagram so if you see uh if you see 27 right so you will see 27 so 27 is the top most snake right so you'll see 27 at 27 i have a snake so if i have a snake then i'll reach one back right so that's a fall okay that i'll have similarly if i'm at 21. so at 21 i'll encounter a snake uh so when i encounter snake so i'll go down two i'll drop down to nine okay that's the thing another thing is let's say if you go to 20 so if you reach 20 then you will not stay at 20 you will go to 29 correct is that also clear to you yes yes yes okay so these things are there now how they will be given to you in in data format so if you will if you will see so like just scroll down a little bit more okay but but first of all you can scroll up i'll read the statement as well for you so the statement uh see if the statement says that you will be given uh n like you will be given an integer n okay that will denote the total number of snakes and ladders okay and you'll be given an array which will be of size 2 cross m okay where where the index 2 cross 2 i and 2 i plus 1 will be up here now what does that mean so can you just quickly uh scroll a little bit down so that i can show it to everyone yeah so if you will see that this test case so if you see 3 comma 32 is given right so so what is the n value n value is 8 so the total number of snakes and the total number of ladders is eight right combined total number of snakes and the total number of ladders overall is eight and what is the size of this array the size of the array is two cross n that is 16. now if you see so you have been given a pair three comma 32 okay the first pair is like you can highlight it as well you can see 3 and 32 right the first the first two elements of the r is 3 and 32 okay yeah 3 and 22. sorry so if you see 3 so from 3 you will get like you will go to 22 because there is a ladder if you will see the diagram so from three there is a there is a ladder so you will go to 22. if you will see five comma eight so at five there is a ladder so you will go to 22. like you will go to eight sorry okay then if you see 11 so at 11 there is a ladder so you'll you will land at 26. can you scroll up in the diagram as well at 11 days a ladder you will go to 26 right uh then if you see 20 so at 20 days at from 20 you will go to 29 correct uh so you can see that in the diagram as well yeah from 20 you will go to 29. uh you can see the other cases as well if you will see so from 17 you are going to four why because there will be a from 17 you are going to four because there will be a snake so you can scroll up to see that from 17 you are going to uh uh this thing um i think it is here this is 17 you are going to four because there is a snake like right okay now this is what you have to do so every snake and ladder pair will be given to you indirectly in this area so like you can see now every i and i plus one pair will be there okay so you have to tell that in the minimum number of dice moves how you can uh like what is the minimum number of uh dice that you have to throw so is that you reach the last cell so is the question problem statement clearly it is clear okay so uh you have any approaches and if the audience uh is also clear to this question so please give us a plus one in the chat okay so what do you think like uh how can we do this problem service uh the first approach that i think of is uh algorithm basically uh what i can do is i insert in a priority queue the num the first element will be the minimum moves that the current number of moves that we have made and the other two will be the current index of the cell that we are currently in so from that cell in one move i can decide how much i either i can go plus one plus two plus three so on to plus six uh and if and for every move i will check that if it is possible to this move and if it is possible then the new cell that i which i will go through from that move does it have a snake or a ladder and if it does then i accordingly redirect it to some another cell else i will insert the cell the cell that i will reach and increment the current number of moves okay uh so what will be the time complexity if you go for the dijkstra approach uh it will be n log answer uh so is there any better approach that you can think of [Music] as in uh where should i optimize in the time complexity part or in the in terms of time okay you can think like whatever you are thinking you can also tell us like you can share your thought processes [Music] so for uh for in the starting cell that when we are one we have to check like six moves here to check right all the time uh like you will be you will be just given the array right the array will be of size 2 cross n and basically n uh n like n pairs are there inside the array right so every everything like the snake and ladder like the ladder pair will be also given and the snake pair will also be given to you right so those things will be given to you you have to decide that what is the minimum number of throws of dye dice in which you can uh reach the final cell that is the 30th cell so i think so the extra will i think that's the only thing that i think it is optimum in this case okay any other thing that is i think in the bfs even bfs can work i mean for uh okay how should i start to code uh you can first of all explain the approach like how bfs like what are you why are you thinking about vfs first of all so sir like i can what i can do is i can firstly create a visited vector and initially store all them to zero that is all of them are unvisited so when in the initially in the queue i will insert the index of the current cell where i'm in and from that cell i will check the all possible moves that can be made and uh all the moves they can be made in one right so the counter will be incremented by one only itself so the in change will be constant so for every cell i will i can accordingly check that if there are snake or a ladder present in that cell and if it takes me back to the cell that i had already visited then there is no need to check that thing again else i will put it back into the queue and proceed accordingly uh so from a particular cell how many types of moves can you have like you mentioned that from a particular cell you will have moves so how many like what kind of jumps or what kinds of moves can you have from a particular cell so the maximum in this dice throw is six right so it can be i can move six moves like plus one plus two plus three or something but in case if they are not possible then uh everyone consider those moves correct so normally you are saying that if you are standing at the current cell then you are saying that current plus one current plus two up till current plus six yes i mean accordingly accordingly we'll check what are the x and y coordinates but okay and why are you thinking of using a bfs approach uh it's like in the grid uh that's mostly what i do sir in this grid or area kind of questions where the grade is given and the minimum number of moves are up uh can you tell us anything special about bfs like why we do so um that's uh i'm generally comfortable with that algorithm so that's uh um basically basically it's because it's uh if the edges are not fitted then it will give you the shortest path now yes that's the shortest minimum number of moves it will give you the answer yes yes that's what i'm saying the change is constant right it is always it will be incremented by plus one itself so we just have to see that the point that we are going is not yet visited so if you want you can start writing the code and tell us how you will approach further while you're writing the code unix explainers as well so you can do what one thing you can maximize the screen there on the top right corner you will see that there is a full screen option okay okay okay so initially all the it is a five plus six grid right yes and it is one two three four on the bottom [Applause] [Music] us so initially i think i will okay uh is the audience in the audience everyone is clear with the question or not i hope that everyone in the audience is also clear with the question and for your better understanding i'll also paste the question link in the chat so if you want to explore this question uh you can open it sideways side by side in another tab if you want okay so if everyone is clear you can hit the like button guys yes go forward so you're saying that you will take a map as well okay why are you taking this map uh first like it will be easier for me to understand that the current cell where i am does it as a snake or a ladder from its beginning that if this cell contains a ladder to go up or a snake to go down so for that first i will store it in a map okay so after that uh and why are you doing i plus is equal to 2 can you tell us about it as well but why are you doing i plus is equal to 2 can you tell us a little bit about it as well sir it is an array right so the first one is the starting element and another plus one is the end part of it that is if it is a ladder then uh the i comma zero is this oh sorry correct i i thought it was year so that was a mistake from my part okay okay so you are pushing one into the queue so here the one it is already visited and i have pushed q in this part so initially the answer will be set to zero that is the number of moves that required we haven't made any moves yet so all the cells that are initially present in the queue i will pop them all at once first okay so this currently is the number of the cell that we are currently in so from this firstly that if you already is 30 that is that we have reached then i will return the number of moves that we have made else if we have not reached the move yet then we will try all possible moves and next is equal to okay u plus i now if next is less than equal to 30 then itself we have to consider this and the next thing that we have to check if capital m if the next it contains any snake or ladder pair in it that is if it is in beginning it has the beginning of a mouth of a snake or the base of a ladder if it is else we can simply push it widget of next we can we have already visited next and we have posted in the queue else x is equal to capital level next and we have to consider this only if so can you elaborate for us a little bit more about this if condition which conditions uh the count condition map dot count condition that you have written can you elaborate it for us the if condition if map.com is equal equal one so if uh in the map in the map i have mapped the beginning that is the base of the ladder to the end point that is the start point to the end point so if this that can be between that can be between uh between a ladder or between a snake right yes yes but it will accordingly redirect it right to whatever point yeah needs to it will accordingly redirect so what so uh if you will uh go back to the diagram like can you just uh escape like okay so like you can put a cross there cut option is there okay so you are basically saying that you are basically saying that suppose you uh suppose you were standing at one and let's say you go to three right so you're saying that if you go to three then you will stay at three you will not stay at three you are saying that you will go to uh 22 correct that's how the game works right we directly go to 22. okay okay so that is what you are also doing yes and if we go to 21 then we cannot uh stay at 21 right we will directly be redirected to 9. okay so uh that's what i have done and here i've redirected it and if the redirected point is not visited then only we have to consider the point is we shouldn't consider it so once all the points are popped we should increase it we should increase the answer by one because we have made a single move here and we have considered all the different points that we can visit okay and there won't be a case right uh where the it cannot be visited uh do you need to think about it i think if a snake exists on the mouth of 30 then i think uh maybe you can return to minus one but i think that uh you will always be reaching there okay so let me try to check if it work what is it you're getting a runtime error yes so are you iterating on any of the indexes like are you missing a particular condition here 31 even and consider that if the next is i have even considered one base indexing right so that shouldn't be a problem if next is less than equal to 30. uh there's one condition that you told but uh in the like while approaching i'm not sure whether you have explained it or not okay uh so you you talked about a condition that uh if uh if you suppose you're standing at 29 then you cannot take a jump of five correct you suppose you're standing at 28 then you cannot take a jump of four so have you taken care of these cases as well yes i have written it right this next is clearly less than equal to 30 so this part works there's no error in this portion let me decrement [Music] so are you sure that you have written the conditions if conditions properly uh yes i am confident on that part [Music] [Music] oh okay expected is also three so should i try to submit yes you can submit it [Music] okay it gives you a wrong answer uh can you just maximize you there's a maximize button there just a little bit uh on the upper side yeah uh so what answer are you getting so ideally the output for it uh the output for this case should be four and you are getting the out like okay you are getting four but the output should be three so that means you are counting more number of moves already let me just check what i'll just simply print out what are the voltages that i'm visiting in one particular cycle why is it giving me three you shouldn't give me three it should give me well [Music] oh wait a minute is it a two times area three and three so let us try the example test is as well so you got the error i told you repetitively that uh the size is 2 0 there are n pairs and so definitely there will be two cross n okay so it is solved so that was simply it was missing this condition now yes it was two cross okay because because i told you that there'll be a total number of ladders and the snakes will be uh n the total number of ladders in the snake so basically the number of pairs will be two crossing and that is what i mentioned in the starting only so you could have uh just thought about it a bit more but that's fine okay okay so now uh i'll move to the next for now uh should i remove my headphones the battery is i think uh if you think that that's fine if you want to use any other thing you can use okay okay so uh you can change your headphones quickly and then uh i'll give you another question so audience is also clear with this question i hope that everyone must be clear with it okay so uh now what i'll be doing is i'll be giving you the another question i'm just waiting for a second okay so can you open the private chat now i also have been given another question you can open it okay this one right yeah let's have a look at this question as well so uh in this question what i'll be giving you is i'll like the problem name is grey code and what i'll be giving you is like i'll be giving you will be given an integer n okay so i'll just give you an integer n and according to that you have to print the grey code for it okay so there is a pattern so can you just go to the go to the editor editor screen so that you can write what i'm telling you uh you can just uh this you can just go to code uh no not this editorial uh go to the writing like coding screen okay yeah perfect put in enter there okay uh now if n is equal to 1 suppose that n is equal to 1 then what will be the grey code for it uh just put n is equal to 1 like just write n is equal to 1 i'll tell you i'll tell you okay so just n is equal to 1 if n is equal to 1 then the grey code for it will be 0 and 1. so just put a put a space and then write 0 and 1 okay so if n is equal to 1 if n is equal to 1 then the gray code will be 0 1 okay is that clear okay okay after that if n is equal to two suppose if n is equal to two okay then what will happen so basically every bit we have to try all the possibilities like it can be zero one zero one just write n is equal to 2 then i'll tell you what is happening here so n is equal to 2 is nothing but 0 0 0 1 1 1 and 1 0 okay now can you tell me can you tell me any pattern in the adjacent uh representation of bits so basically every bit has two options right so it can either be that is fine that is fine because we are talking about bit representation so that is fine but can you tell me anything about the representation or you can see n is equal to 3 also you can scroll down and see example number 2 if you see n is equal to 3 so can you tell me any pattern if you will see the pattern so every adjacent every adjacent player differs by only one yes if you see n is equal to one then the adjacent bits zero and one differ by one bit only if you see n is equal to two so zero zero and zero one differ by one bit only and zero one and one one also differ by one meter one bit only then uh one one and one zero also differ by one bit only correct that is the right bit uh if you see n is equal to three then for n is equal to three you will have zero zero uh like three zeros then after that the second one is zero zero one so they differ by one bit every pair that you will see here it differs by one bit okay so i'll i'll give you a particular value of n and that will be within a range let's say it can be 15 or 16 something like that and what you have to do is you have to tell me that okay what will the gray code sequence for it such that uh every bit is alternating in this fashion like like every every adjacent pair has only one bit different okay okay so is the is the question clear to the audience as well so the question is clear to you service yes yes so it uh i mean the the bit wise basically this or of adjacent elements should be a power of two exact power that that's the one thing right no no that that is not the case that is not necessary the necessary thing is that every adjacent pair uh will be uh differing by one bit only if you see any pair like if you see triple one and one zero one for n is if you can highlight this triple one and one zero one so they differ by one bit only if you see one zero one and you see hundred uh like one zero zero so they differ by one bit only so you have to re like you have to put all these uh all these representations in an error list or in a vector and you have to return this final answer for for the nth sequence okay i'll i'll paste the link everyone just give me a second i'll paste the link of this question as well ah and can you tell me one more things let's say n is equal to three so how many elements i am having can you count that [Music] we have eight elements eight elements okay when n was equal to two then how many elements was i having four so something when n was equal to one two to the power m so every uh like if you will read the problem statement now so it will be much more clear to you you can scroll up okay so it says that you will be given a number n and you have to generate the bit pattern from 0 to 2 to the power n minus 1 okay so basically there will be 2 to the power n n representations for a particular n okay now how will you do it can i think for a bit uh just whatever you are thinking you can also share your thoughts with us as well and in the audience also if they have any approach some of the people have given their approaches and i think that's correct also other people can also tell us about their approaches if you are able to solve this problem then i'll ask the follow-up question there is a one approach that i think so basically see they differ by one bit itself by default means that uh for that for let's suppose for i then i plus 1 we add a power of 2 to it right some power of 2 is added to it again so uh let's suppose that if we begin from 0 then i can take another let's suppose 2 i add 2 to it so for another part it should contain 2 and plus some another bit and plus some another bit uh that's i think how we can generate it and okay you have to notice that you have to uh you have not you do not want to return the decimal representation of it okay yes represent the you want to return them in form of strings string it has to be instant formatted uh you can just think about it because you have to return the strings so how can you generate the strings and can you take a help of something for generating the strings you have to think in this direction i know the first i'm thinking about how i will arrange this and once i get a solid this i will explain how to generate these things so what approach is coming to your mind currently i i am thinking that there might be some pattern here as to how they can be arranged as well and then can you get can you keep can you guess that pattern by looking at n is equal to 1 and n is equal to 2 n is equal to 3 at least okay so what's the difference between n is equal to 1 and n is equal to 2 any any like just think about it you can you have written it in on the right side n is equal to 1 and n is equal to 2 what's the difference between the two i think in the uh the first part they have just added one unsaid bit and then no it is and meanwhile in the audience if you like the quality of the questions that we have taken so all of you can give us a plus one in the chat so that i can understand that you like the questions that we have taken and please hit the like button guys i can see the number of uh people watching are more uh compared to the likes so please hit the like button if you haven't uh already uh i think i got i have figured out the pattern okay so uh in this case let's suppose i will explain with n is equal to 2 so the first thing that if you notice that if i add 0 to here here here and here it it won't change the answer one bit right next case okay that is if i and now the current that bit is set right this is unsaid bit the extra bit that i have added is unset so in the next case when i will can you write it like you are writing for n is equal to 3 so can you write it for us okay so in this case once i have the extra bit then was first case it was unset in the second case i have the bit is set so this this time we will reverse it basically we will reverse this thing while adding we won't add a hundred to one zero and we'll reverse this thing so what we will get is this number so when when i'm transitioning it to four from n is equal to three this can you tell us can you can you tell us again like how you got uh from n is equal to how you generated n is equal to 3 can you tell us again by writing n is equal to 2 then can you tell us how you generated n is equal to 3 once again uh sir so the thing that i am saying is in the first case when n was equal to 2 suppose that n was equal to 1 so how did how can you generate n equal to 2 from n is equal to 1 okay so what i what i'm telling is basically for this is well i am writing for n is equal to 2 what i have done is this this for n is equal to 2 and this is a reverse of it basically ok am i clear till now can you tell me like how did you like can you let's see you are telling me to generate n is equal to n is equal to 3 for n is equal to 2 but can you tell me how will you generate n is equal to 2 from like how will you generate n is equal to 2 can you tell me that my question is this now uh okay i will first explain that so for n is equal to 1 this was our base sequence this is the base sequence and this is the reverse of it basically so okay i'm making an extra bit in the first case when it was sunset so for the first half it shouldn't change anything right it is still in the gray code format so in the second case i will simply set that thing so here i have generated n is equal to 2 okay while generating n is equal to 3 since the first half still holds to the law so there is no problem on that front uh can you also move down in the second or like in the left half you can you scroll up so that we can also see the what is n is equal to 3 you can scroll like you can scroll down basically this is n is equal to 3 yeah so first half what which first half is for n is equal to 2 and the second half is simply the reverse of it is appended to it okay now i had a extra bit which is basically unset and in the next case i'll simply set it now since these two are basically the same and only one bit differs right okay it was zero and now they differ by one bit and it's the first half and the second half both are already in the gray code format only one extra common bit was added to all of them so it shouldn't violate any property for gray code and similarly so can you can you summarize okay so can you summarize how you're getting the nth grey code sequence so for getting the nth gray code sequence from the n minus one at the gray code sequence the current sequence let's suppose it is s will append the reverse of s let's suppose it is sr will append sr to s and for s we will attach an extra bit bit unsaid bit to the left most part of the elements that is in this case let's suppose for n is equal to four i copy paste it again and i will add one extra zero here to all of them or extra one here to them and we can basically generate we can keep generating basically we can keep generating the n minus whatever for the first half you will append a zero and for the second half you will append a one yes yes so first if the sequence is s i will reverse it i will do sr i will append both and an unset between the appended to the first half and a set between the appended to the next half okay so you are saying that for the nth uh sequence you will take help of what for generating let's suppose the base sequence will be n is equal to one okay okay so let's suppose if i am trying to algorithmically explain it the for the base sequence let's suppose i will have a vector string previous which will tell me the sequence in the pre n minus 1 and sequence so while getting the nth sequence the first thing that i will do is store this sequence i will add append 0 to it and store it in some vector i will append one to it store it in another vector i will reverse the first second vector and append both and store them back to the previous part so you can maximize the screen now and start writing code if you are comfortable okay so vector bring previous use so this is the base base case which i am generating i will push back the zero and the one string split now if n equal to equal to one i don't need to do anything i already have previous okay so 4 and i is equal to 2 comma i is less than equal to n comma i plus plus so for every every increment so first what i will do is i will add previous i will copy it to some uh new vector let's suppose i give this as temporary temp so next what i will do is i will iterate over all the elements of the time next okay next what i will do is i will take another vector let's suppose i will name it temp 2 i will take it please i will reverse this vector m2.begin m2.end i have reversed the vector and what i am going to do is i am going to append one to this thing so i will basically what i will do is i will take all the elements of the temp tool and append them one by one temporarily plus this m dot push back m2 i and in the end i will assign the previous vector to temp attempt to the preserver sorry and just for the clarity let us see the the sequence in each iteration what the sequence is generated what is it oh sorry it was yeah it was string format that you have to return mdm still getting some runtime errors oh here so this is the let's see custom input i will give a send out you can maximize the output stream here so so this is the second this is the third this is the fourth this is the but you only have to get the nth oh yes sir that i know i'm just for clarity purposes i was showing this thing and in the end we have to simply return the previous vector which contains the answer so i expected uh it works let me simply try for the last element 16. so let me submit and see so yes it does plus perfect now defines than the two part n solution okay uh now there's a follow-up question for this okay so you can do one thing you can just quickly reset the code there just quickly reset it up okay uh all right so just quickly copy n is equal to two now n is equal to to just quickly copy it from there n is equal to copy from there okay and paste it on the coding screen okay perfect so now suppose that instead of asking you like here what i'm asking is i'm asking the bit representations indirectly correct i'm asking the bit representation of every number but in terms of strings basically but suppose if i ask you about the integer representation then how will you do that uh it won't change much in the like i was adding zero right okay so so suppose is equal suppose n is equal to one so for n is equal to one what will the what will be the integer outputs that like what will the decimal numbers that you will give for that finish right foreign uh for n is equal to 1 it will be 0 and 1 but when in n is equal to 2 when i'm doing n is equal to 2 so in the algorithm when i was adding 1 basically instead of adding 1 i will add basically we are adding a power of 2 right creating a power of 2 to it so in the for in this case it was 2 so 0 and 1 so for 1 and 0 it will be 3 and it will be 2. so when i'm doing the same thing for 3 when i reverse it i will add 2 to the power this is the next one that is 4 for this thing so it will be 6 because you are because you are changing the left most bit now again like again again you are incrementing the left most bit yes so it won't change much it will just be adding a power of two to the whole thing so it will be the same okay uh correct that's great uh so this like this was these are the questions that i wanted to ask and you have also clearly answered the follow-up question for this basically in the follow-up question i asked him this thing that suppose you have zero one right so maybe you can you could have like explained it in a much better manner but uh basically he's saying that's up like i'm asking him the decimal representation of everything right so he say like i'm saying that if n is equal to 1 then the decimal numbers will be 0 1 if n is equal to 2 then the sequence looks like 0 0 0 1 1 1 and 1 0. so what is the corresponding decimal output for it it's nothing but 0 1 3 and 2. so that is what i'm asking that for every instead of printing the strings that is the bit representation you give me the decimal representation for it okay then he is saying that if you will observe the first case so now for n is equal to 1 for n is equal to 1 you have 0 1 now for n is equal to 2 you have the first part is the same and the second part is nothing but 1 1 and 1 0 that is nothing but opposite of 1 and 0 and you are adding 2 to it ok yes that is what you are saying correct yes and every time your your power is increasing okay yes so that is great uh so now before i give you any feedback so like can you tell us your experience about this mock interview uh it was a pretty unique one i never given a mock interview before and uh i think it should uh it really simulated the whole interview process i mean when that matter when you got stuck but interest is still going so you have to keep communicating keep getting your thoughts on the other end so i i'm not saying that i was entirely polished in a manner but i think this will clearly help me in upping my skills and be better in a proper interview uh uh so do you want a feedback from me oh yes i will definitely like the feedback okay so before i give a feedback so in the audience uh for those who have liked this interview for those uh who for those people who think that this these questions were a little bit new to them maybe they can be easy or difficult depending on your practice but if you have like if you like this then all of you can give us a plus one and hit the like button as well guys uh now coming to the feedback for you service so i think in the first question uh i told you a lot about uh this thing about the rsis that is to cross m but you did not uh think about it while writing the code so that those were some mistakes that you were doing and also when you're in an interview here i have given you a compiler right suppose if i was doing this uh with you on a google doc so if i was doing the interview with you in on a google doc that that generally companies like google or other companies might do so in that case you will not be able to see the error by running the code okay and like uh so this is one thing like you should have thought a bit more before uh directly compiling and testing the code here you had a compiler so i allowed you to do the compile and run thing but you will not be always allowed this thing so you can just think about it a bit more and another thing is like uh you can explain the things a bit more better like uh when i asked you like why you are using bfs so you said that i i have been using it for some long time but you could have come up with the approach what are the what is the benefit of bfs compared to dfs and stuff you could have told that okay it gives you the shortest thing and everything yeah yeah so you you i know that you knew this thing that bfs will give you the minimum dice throws but you could have told us about it a bit more right so that was one another thing and in this question also uh you were writing the code like like very uh smoothly but still you did not explain it very much so another thing is that you could have explained it a little bit more and maybe you could have made it a little bit more readable as well and uh you have written it in iterative manner that's really great but you could have also told that you could have done it using recursion okay you can do this question using recursion as well so you could have told about it as well and there was another approach like bit set approach is also there in which the like in this case your time space complexity is order of two to the power n minus one but you could have used a bit set as well so that will also like improve your space complexity so you did not tell about the recursive approach and the bit set approach so maybe you could have thought a little bit more about it as well but these are the feedbacks but overall it was a good interview and i liked interviewing you maybe you'll improve with time as well so i wish you all the best for the placement and in the audience also you can just give us a plus one in the chat before we go and hit the like button as well uh and thank you service for joining uh for this mock interview and giving us your precious time so thanks a lot service yes do you have anything else to say about this interview no no nothing okay so thank you service uh now uh coming back to the audience so thanks a lot everyone for uh coming to this live mock interview and again i would like to remind you that if there is any one of you who wants to give the mock interviews live with gfg so they you can see down there in the description of this video there will be a google form uh attached for the live mock interviews so you can uh you can fill that form and our team will reach out to you for the mock interview based on your schedule so you can make sure to do that and someone is talking about the question link for you so you can google it out it you will get that link also the grey code part two the follow-up question for that also you'll get the link chetan okay please bring more such interviews uh yes definitely shlok we'll try to bring more such interviews okay uh so thank you everyone for joining this uh and make sure to hit the like button and comment down helpful or a plus one if this interview uh was helpful for you and thank you everyone for joining and have a great day uh like and make sure to keep practicing keep coding guys thank you for joining

Original Description

Watch this mock interview to evaluate your strengths & weaknesses alike. A great way for self-examination, make sure to formulate your tactics before your next interview! In this webinar, we have Sarvesh Mukund Donga, who will be interviewed by Yash Dwivedi, mentor at GeeksforGeeks. For Complete Interview Prep, visit - https://practice.geeksforgeeks.org/courses/complete-interview-preparation?utm_source=youtube&utm_medium=courseteam_main_desc&utm_campaign=live_mock_dsa Fill these forms to share your webinars with us: Live Mock https://docs.google.com/forms/d/1tTEAB8dFXETEVgg6pAk2Zu1nC8y4wgwvYU4HcW8cQdU/edit?utm_source=youtube&utm_medium=courseteam_main_desc&utm_campaign=live_mock_dsa Interview Experience https://forms.gle/YLG5C8d6SJ6adbCQ7?utm_source=youtube&utm_medium=courseteam_main_desc&utm_campaign=live_mock_dsa Follow us on our social media handles to stay updated! Instagram: https://www.instagram.com/geeks_for_geeks/?hl=en Twitter: https://twitter.com/geeksforgeeks​ Telegram: https://t.me/s/geeksforgeeks_official #codingpreparation #coding #techincalround #datastructures #MockInterview #InterviewPreparation #LIVE
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from GeeksforGeeks · GeeksforGeeks · 0 of 60

← Previous Next →
1 How I got into Walmart | Shailesh Sharma
How I got into Walmart | Shailesh Sharma
GeeksforGeeks
2 Upgrade yourself In 29 Days | GeeksforGeeks
Upgrade yourself In 29 Days | GeeksforGeeks
GeeksforGeeks
3 Learn AWS Fundamentals For Free
Learn AWS Fundamentals For Free
GeeksforGeeks
4 Conversation With Young Achievers | Meet the winners of Bi-Wizard Coding Contest | GeeksforGeeks
Conversation With Young Achievers | Meet the winners of Bi-Wizard Coding Contest | GeeksforGeeks
GeeksforGeeks
5 Meet The Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
Meet The Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
6 Interview Prep Strategies | PayPal
Interview Prep Strategies | PayPal
GeeksforGeeks
7 OLX Interview Preparation Strategies | Hukam Singh
OLX Interview Preparation Strategies | Hukam Singh
GeeksforGeeks
8 Meet Some More Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
Meet Some More Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
9 Live Mock DSA
Live Mock DSA
GeeksforGeeks
10 Microsoft Azure For Absolute Beginners
Microsoft Azure For Absolute Beginners
GeeksforGeeks
11 Python for Data Science | Data Science Master Bootcamp | Arpit Jain
Python for Data Science | Data Science Master Bootcamp | Arpit Jain
GeeksforGeeks
12 Getting Started with Data Analysis | Data Science Master Bootcamp | Ashish Jangra
Getting Started with Data Analysis | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
13 How to prepare theory subjects for SDE interviews | Geeks Summer Carnival 2022
How to prepare theory subjects for SDE interviews | Geeks Summer Carnival 2022
GeeksforGeeks
14 Get Your Tickets To The Geeks Summer Carnival | GeeksforGeeks
Get Your Tickets To The Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
15 TED Talk Data Analysis Project | Data Science Master Bootcamp | Ashish Jangra
TED Talk Data Analysis Project | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
16 How I Secured AIR 9 in GATE'22 |  Tushar
How I Secured AIR 9 in GATE'22 | Tushar
GeeksforGeeks
17 Learn Java Backend Development | Geeks Summer Carnival | GeeksforGeeks
Learn Java Backend Development | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
18 How to Recognize which Data Structure to use in a question | Geeks Summer Carnival | GeeksforGeeks
How to Recognize which Data Structure to use in a question | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
19 Learn Data Structures and Algorithms | GeeksforGeeks
Learn Data Structures and Algorithms | GeeksforGeeks
GeeksforGeeks
20 Interview experience at Flipkart | GeeksforGeeks
Interview experience at Flipkart | GeeksforGeeks
GeeksforGeeks
21 Lets Prepare for GATE'23 the Right Way | Sakshi Singhal | GeekSummerCarnival
Lets Prepare for GATE'23 the Right Way | Sakshi Singhal | GeekSummerCarnival
GeeksforGeeks
22 Highest Paying Jobs in 2022 | Ishan Sharma | Geeks Summer Carnival 2022 | GeeksforGeeks
Highest Paying Jobs in 2022 | Ishan Sharma | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
23 Geeks Summer Carnival 2022 | 5th April- 11th April | GeeksforGeeks
Geeks Summer Carnival 2022 | 5th April- 11th April | GeeksforGeeks
GeeksforGeeks
24 Preparing for SDE interviews | Soham Mukherjee | Geeks Summer Carnival 2022 | GeeksforGeeks
Preparing for SDE interviews | Soham Mukherjee | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
25 Full Stack Development with React & Node | Utkarsh Malik | Geeks Summer Carnival | GeeksforGeeks
Full Stack Development with React & Node | Utkarsh Malik | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
26 Introduction to Open Source and Roadmap to GSOC 2022 | Geeks Summer Carnival 2022 | GeeksforGeeks
Introduction to Open Source and Roadmap to GSOC 2022 | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
27 Web Scraping in Action | Geeks Summer Carnival 2022 | GeeksforGeeks
Web Scraping in Action | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
28 Getting Hired at BITCS via GfG Job Portal | Get Hired With GeeksforGeeks
Getting Hired at BITCS via GfG Job Portal | Get Hired With GeeksforGeeks
GeeksforGeeks
29 How to build a faster landing Page | Geeks Summer Carnival 2022 | GeeksforGeeks
How to build a faster landing Page | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
30 Geeks Summer Carnival | 5th To 11th April, 2022 | GeeksforGeeks
Geeks Summer Carnival | 5th To 11th April, 2022 | GeeksforGeeks
GeeksforGeeks
31 How to get ideas for Startup | Geeks Summer Carnival 2022 | GeeksforGeeks
How to get ideas for Startup | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
32 Journey from Tier 3 to JusPay | GeeksforGeeks
Journey from Tier 3 to JusPay | GeeksforGeeks
GeeksforGeeks
33 Geeks Summer Carnival 2022 | GeeksforGeeks
Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
34 Dispelling Myths and Pre conceptions of Programming Languages
Dispelling Myths and Pre conceptions of Programming Languages
GeeksforGeeks
35 Must Do System Design Questions
Must Do System Design Questions
GeeksforGeeks
36 Understanding Sorting Techniques in an hour | Keerti Purswani | Geeks Summer Carnival
Understanding Sorting Techniques in an hour | Keerti Purswani | Geeks Summer Carnival
GeeksforGeeks
37 Get Hired at NEC | Job-A-Thon 8
Get Hired at NEC | Job-A-Thon 8
GeeksforGeeks
38 Journey from Tier 3 college to Microsoft | GeeksforGeeks
Journey from Tier 3 college to Microsoft | GeeksforGeeks
GeeksforGeeks
39 Get Hired with GeeksforGeeks at SuperK | Job A Thon 8
Get Hired with GeeksforGeeks at SuperK | Job A Thon 8
GeeksforGeeks
40 GeeksforGeeks: Redesigned
GeeksforGeeks: Redesigned
GeeksforGeeks
41 From Tier 3 to cracking multiple interviews | GeeksforGeeks
From Tier 3 to cracking multiple interviews | GeeksforGeeks
GeeksforGeeks
42 Live Mock DSA
Live Mock DSA
GeeksforGeeks
43 Youtube Data Analysis | Ashish Jangra | GeeksforGeeks
Youtube Data Analysis | Ashish Jangra | GeeksforGeeks
GeeksforGeeks
44 DSA Self-Paced Course Preview | Sandeep Jain | GeeksforGeeks
DSA Self-Paced Course Preview | Sandeep Jain | GeeksforGeeks
GeeksforGeeks
45 GATE Live Classes | Prepare for GATE CS 2023 | GeeksforGeeks
GATE Live Classes | Prepare for GATE CS 2023 | GeeksforGeeks
GeeksforGeeks
46 Journey from JIIT to Adobe
Journey from JIIT to Adobe
GeeksforGeeks
47 Life Is Unfair Ft. Shonty badmash | LIVE Discord Session | A GeeksforGeeks Exclusive
Life Is Unfair Ft. Shonty badmash | LIVE Discord Session | A GeeksforGeeks Exclusive
GeeksforGeeks
48 Interview Experience at Google | Tech Dose
Interview Experience at Google | Tech Dose
GeeksforGeeks
49 Live Mock DSA
Live Mock DSA
GeeksforGeeks
50 Interview Experience @ Amazon | GeeksforGeeks
Interview Experience @ Amazon | GeeksforGeeks
GeeksforGeeks
51 My journey through the tech world from India to US | Vidushi | GeeksforGeeks
My journey through the tech world from India to US | Vidushi | GeeksforGeeks
GeeksforGeeks
52 Complete Interview Preparation Course | GeeksforGeeks
Complete Interview Preparation Course | GeeksforGeeks
GeeksforGeeks
53 Live Mock DSA
Live Mock DSA
GeeksforGeeks
54 Getting Hired at FiftyFive Technologies | Job-a-thon 9.0
Getting Hired at FiftyFive Technologies | Job-a-thon 9.0
GeeksforGeeks
55 GFG Karlo, Ho Jayega | GeeksforGeeks ft. Khaleel Ahmed
GFG Karlo, Ho Jayega | GeeksforGeeks ft. Khaleel Ahmed
GeeksforGeeks
56 How I got job offers from 2 big companies : Arcesium & Microsoft | GeeksforGeeks
How I got job offers from 2 big companies : Arcesium & Microsoft | GeeksforGeeks
GeeksforGeeks
57 LINUX for Beginners | GFG x Itversity
LINUX for Beginners | GFG x Itversity
GeeksforGeeks
58 My interview experience at Walmart | GeeksforGeeks
My interview experience at Walmart | GeeksforGeeks
GeeksforGeeks
59 Get Hired at Speckyfox
Get Hired at Speckyfox
GeeksforGeeks
60 Live Mock DSA
Live Mock DSA
GeeksforGeeks

Related Reads

📰
Microsoft said the patches would get bigger. I measured how much bigger.
Measure the impact of Microsoft's patches on Windows updates to understand the growth in size due to AI-powered vulnerability discovery
Dev.to · Erik Rekola
📰
The AI Paradox: Why Search Engines Still Need the Human Touch in 2026
Learn why human touch is still essential in search engines despite AI advancements in 2026
Medium · AI
📰
Looking Like You Know AI and Actually Knowing AI Are Two Different Things
Distinguish between superficial AI knowledge and genuine understanding to effectively apply AI in the workplace
Dev.to AI
📰
I Traced an AI Startup’s “10x Faster” Claim Back to Its Source
Learn to critically evaluate AI startup claims by tracing their sources and understanding the context behind benchmark numbers
Medium · Startup
Up next
PLATO Exoplanet Hunter Launch 2026 Searching for New Earths in a Warming World
Tech Folk Insights
Watch →