How to Recognize which Data Structure to use in a question | Geeks Summer Carnival | GeeksforGeeks
Skills:
Algorithm Basics80%
Key Takeaways
Explains how to recognize which Data Structure to use in a question at Geeks Summer Carnival
Full Transcript
hi seems like i'm live now so may i have a quick attendance kind of thing i know it's not valid here but still i would like to know how many people are here in the stream itself so we would just wait for around one minute itself and then we would proceed right away okay so let me see how many people are there at least if you're watching just give me a quick one in the chat at least a high would solve the purpose okay okay so we have some people live now at the moment okay so without any further ado let's start then okay so today we have a very interesting topic to cover okay today if we would be solving question then we would be trying to bring down the algorithm the focus today would be lesson algorithm and then we would try to see what are the requirements we need okay and then we would see how to get the best data structure to use on that particular thing itself okay so yeah fair enough so let me just present my screen and we can start right away okay yeah just a sec okay fair enough so just a second okay so let me just share my screen hi paul someone how are you so yeah fair enough so let's discuss now okay so the first question would be we are given an array of n positive integers it means that every element would be greater than zero okay so we have three sets of numbers negative zero and then we have the positive values okay and and then we need to find the k largest elements from the array itself okay so it's a simple question bots are elements largest k values the output would be printed in decreasing order okay so what we can do is we can see that 12 5 7 8 7 1 and 23 7 8 7 is the largest value and then 23 is the second largest value and we need to return two values according to the decreasing order now let us try to think okay the first the first way to solve this would be simply to sort the array sort the array and then reverse the array itself and then find the k largest but instead we can skip that reverse part also okay so what we can do is we can simply have something like 1 5 12 23 and 7 8 7 itself then what we can do is we can start iterating from the back and then we can take up this number insert it to a vector then we can take up this number we can insert it to a vector we would keep inserting numbers till we have k elements itself okay so what would be the time complexity of this approach the time complexity okay just let me just arrange this to a very yeah now it seems correct okay right so now the approach is very simple but what we are basically doing here we are doing a in place sorting that would do as n log n okay we can use quicksort or something and then fast forward we are again iterating would make it big o of n log n so can we do better than this or not okay we know that the value of k is less than the value of m itself so let us try to optimize our approach okay the second optimization of our approach can be that we take hold of first first k k elements in the array first k elements in the array itself okay so how what can we do is how look pali k elements then what we can do is we can take hold okay suppose there are k elements okay let me just try to do the dry run itself okay so we have 12 5 7 8 7 so we have 12 5 7 8 7 and then we have 1 and 23 etc now what we can do is i told that the focus would be less on algorithm and more would be on data structure today now what we can do is first we can insert these two elements why because we are told that the k is two here so what we can do is we can insert twelve and five then we come across seven eight seven then we see that if this 787 787 is greater than the minimum element of these part or not yes 787 is definitely greater so we would bring out this 5 and we would assign 7 8 7 okay then we come across 1 the minimum element of this is 12 and 1 is less than 12 so our values in this circle won't be updated then we come across 23 so the minimum value here is 12 and 23 is greater than 12 so what we would do is we would update 12 to 23 and we would okay then we are replacing that element okay we are replacing that element and then we are moving forward at the end whatever we are getting in a nutshell that is our answer itself hope i am clear till this point okay so now why is this working okay why is this working so why is this working so this is working because we are comparing the minimum element okay why minimum not the maximum we have two options to either compare the minimum to either compare the maximum so we want that k largest value so if we want to find the k largest value then the minimum should also be a very strong candidate for being the maximum okay hope i am clear till this point okay then what we do is we take hold of the minimum and then we update the minimum itself okay so can i have a quick yes or no that i am clear till this point or not okay quick yes or no that i'm clear till this point or not i would wait for just one minute itself and then i would proceed okay how are we doing itself just tell me if i'm clear till this point or not hi paul thanks a lot richie thanks a lot kyle can i have one or two more replies and i can proceed forward okay okay four people are following up thanks a lot so let me just go to the clear it sir please what clear it can you tell me what what do you mean by this okay fair enough so we have a bag kind of thing we have a big bag and we have many elements here so again telling you suppose this is the smallest element then we need to update that also so if we start updating the minimum element then we can see that the maximum element if we have a greater element than that it would automatically be updated okay i would repeat don't need to say please that's absolutely fine you don't need to say please i would just do the iteration again okay so see i'm telling you what is happening okay and we take the minimum potato okay and we start updating that so suppose there is a large bag kind of thing okay large back kind of thing and we have a minimum potato and we have a mini suppose this is size 1 this is size 2 then we have a size of 1.5 then we have a size of 2.5 okay so what we do is we take this 1.5 we remove this and we assign it here 1.5 then we come across 2.5 we can see that minimum value is less so we are updating this value only okay so if the next value is 3.5 you can see that even the maximum is now being the minimum okay so you have a change of rollover okay now let me tell you this okay suppose with respect to that we have 5 and we have 12 so the minimum value of this is 5 itself then we come across 7 8 7 so if we come across 7 8 7 and it is it is less than it is greater than 5 so we replace 5 with 7 8 7 and now the minimum element is equals to 12 okay then we come across one the minimum element it is less than the minimum element we won't update it then we come across 23. 23 so now 23 is greater than the minimum element so see earlier this was the maximum element but now even the maximum element is getting updated to 23 itself okay that is one so now am i clear sumit and on card am i clear or not can you please give me a one in the chat and i would quickly proceed okay so what are the requirements okay what are the basically the requirements of this approach so what we want is okay we would talk about the cost and all after this okay requirement okay you both would give me a treat okay now what are the requirement in this okay so first we are inserting elements okay so data structure would hold elements next we need the minimum at each step okay so what we want we want the minimum at each step okay so we want the minimum at each step so if we want the minimum at each step we need to update it also updating means that we need to remove the minimum and insert a new element okay so insert insert option should be there and then removal of minimum element removal of minimum element itself okay and we want all this thing to be very cost effective okay so whenever we think about minimum at each step or we want sorting at each step we should think about only one data structure can you tell me what would be the data structure that can be used at this point just tell me looking at all the requirements tell me the data structure that you might need so we can insert elements we can remove elements and we can get the minimum at each step so but our concept what data structure can be used at this point see we should have the basic functionalities with the cost and all so we should know that map has a insertion cost of login map has a deletion cost of login map has a find function of login okay these all things should be known then we should also know about set also we should also know about array also okay these all things should be known suppose we want unique elements okay i'm just telling you the gist you can quickly see the recording at this point so suppose we want all the unique elements in sorted order then we should use set if we want all the elements but not unique there might be repetition then we should think about what we should think about multiset okay fair enough yes ayush agarwal you are absolutely correct okay so we would be using priority queue okay i would just write pq or let us write priority queue okay priority queue or basically we can write it as the mean heap thing okay those who don't know what is priority queue can say that it has all the functionalities that it is listed here with everything the cost with a log and approach okay now before using that element before using the data structure just see if we are able to improve or not because if using a new data structure we are not able to improve there is no point in doing that okay so what we can do is we can just go back okay we can just go back and then we can read the spot only and then let us see so the number of elements so the number of elements is n itself okay so at most we would insert all the elements so it would be k operation then again the remaining operation also so we can have n plus k log k itself okay all the elements have their respective priorities in priority queue okay we would be talking about so in priority queue okay this priority thing this priority thing okay what do you mean by priority of an element so you can declare the priority of an element how you can declare the priority of an element according to the smaller element small or large okay or big or small what do i mean by this that if we assign a min heat okay if we assign a min he or the default priority q in c plus plus stl then the minim then the maximum element so sorry this is not the default one okay so this is the mean heap thing and this is the default one okay so now if we have a min heap priority queue then the smallest element would be at the top if we have a maxi priority queue then the maximum element would be at the top okay and the order would be maintained am i clear sumit okay now let us see the working of priority queue so we have this simple part okay fair enough now what we can do is we can have a priority queue priority itself okay of ink and we would name it as pq then what we would do is pq dot push the element one okay and then i would just copy paste this okay by the way to select the whole line it is command l or control l in windows itself okay so suppose we insert 4 then we insert again 0 then we insert again 10. so now if we print the top element of the priority queue pq dot the top element then what would be the value itself the value is 10 that is the maximum element is at the top itself okay so now we know that if we have a mean heat so if we have a max c then the maximum element would be at the top okay so now if we want to construct if we want to construct a min heap in c plus plus stl then the syntax is a bit different and it's too long not too long it's a little bit long and it's difficult to memorize okay so is there any shortcut or not and there is a shortcut but that is a basically a trick okay that is basically a trick so how many of you have difficulty in initialization of min heap in c plus stl okay so we can say that our problem is now min heap in c plus plus st so if you look at the stl to implement mean heap it is a little bit difficult okay so how many of you have this problem that you do you are not able to memorize this if there are more than one people i would be more than happy to explain you a trick so that we would convert a max heap into minheel by adding just a single integer just a single integer so quickly give me a 1 if you want to know me if you want to know it so let us see okay so we have 10 we have 1 we have 2 and we have 5 okay now if we insert this in the priority queue suppose we insert 10 then 10 would be inserted at the top then 5 then 2 and then 1. this would be inserted like that now what i see is what i see is when we insert in the before inserting so just before insert okay multiply it with -1 and after taking out after taking out again multiply it with minus 1 this is what you need to do just this nothing more nothing less this is the only thing that you need to do okay now let's talk about this thing why this is working so suppose before inserting into the priority queue i have minus 10 then i insert minus 1 so minus 1 is greater than minus 10 so it would be at the top now if we insert minus 2 then this 10 minus 10 would go down and minus 2 would get inserted at this position then we have minus 5 then we access the top element and just after taking it out we multiply it minus 1 with again 1 that is equal to 1 now suppose we pop this element then we again have minus 2 multiplied with minus 1 then we have 2 so we can see that by using the default one in c plus plus stl we are able to implement min heap and this is a very popular trick that is used in competitive programming okay so i hope this would need an applause but i don't need an applause just send me a quick two in the chat or a thank you would solve the purpose okay and then we would proceed okay but i'm am i clear with this idea or not just before inserting multiplied with minus 1 after taking out multiplied with minus 1 okay because i see that programming shouldn't be just mugged up and understood okay because if i know that vector vector the bracket and end and the name i want i would use the same thing priority q bracket the data type i want and the name itself okay so this is a very good thing i observe thing okay thank you you are most welcome ronna thanks a lot ariji thanks a lot richie thanks a lot sir emil okay so in this problem what we need to do is we need the minimum at each step so we want the min heap so we now have the min heap so what we would do is we would have the same type okay we would have the same type and we would start the implementation live itself okay so let us do the implementation okay so now instead of a rr i would make it a itself okay then what i would do is i would have the prior by the way just after the stream just towards this end of the stream i would also tell you one more alternative of a data structure just wait for it and that would be absolutely fantastic trust me okay priority q priority queue itself and then we have the in i like to name it as pq itself okay then what we do is we have a for loop in i is equals to zero i is less than equal i is less than k and i plus plus because it is zero index and then pq dot push the i itself okay a of n so priority queue of in data structure because we have end and then we insert all those elements okay then what we do is we have the we start comparing that okay but we are making a mistake if you observe i is less than n and then for the rest of the elements we would iterate but before inserting i told that i would just multiply it with -1 and with maxi would be change it to my mini okay this is how it would be changed this one integer would change all the game we have okay then what we would do is we would take hold of the top element top element would be minus 1 multiplied with pq dot top itself we would take hold of the top element okay and then we are multiplying with minus 1 then we would have the minimum element the original minimum element because minus 1 into minus 1 is 1 and multiplying 1 with any number won't disrupt the value of that number that is the reason we have -1 excel then if the value tp is less than the current value what we would do is pq dot pop itself then we would again push this element minus 1 multiplied with the number itself okay and then we would proceed okay i hope that after this we would have this because if we are inserting elements we make sure we are popping up the elements so the number of elements k is kind of preserved okay so if that element is there we would just push and we would pop that element next what we would do is now we have the minimum element but we want that in decreasing order so we would have the vector of end to save the answer and while the priority queue is not empty not empty what we would do is answer dot pushback okay pq dot top multiplied with minus 1 okay then what we would do is pq dot pump so that we have the next element then after that we have all the elements in sorted order but we want the reverse of it so i would just show you and then i would just reverse it okay so i would return the answer itself and then let us just compile and run and we would see that okay so we want 787 but the output here is 23 and 787 just the opposite of this so what we can do before returning is answer reverse answer dot begin comma answer dot end itself okay now let us see that okay we have the particular value yeah the java minus one trick in java in priority queue would solve the purpose don't worry about that okay so we have successfully solved so what i want is i want to know if you are able to gain something from this or not okay and then we would move to the next problem which is a very famous problem and then we would just end the string okay and this time i would tell you a very good trick of this this would work this trick would work in all min maxi to convert it into min heap if you have min heap as the default one you can convert it to maxi by using this okay so it can be toggled minips you can be converted to max heap and max heap can be converted to meaning by using this strip okay so now in this question what we need to do is we need to find so fb show previous slide this previous slide yeah sure quickly take a screenshot okay one two and three i hope you have taken the screenshot you don't need to say please please don't say me please i'm not accustomed to saying please you are a human i am a human i respect you you respect me if you use max heap if we use max heap seven eight seven would be on the top right yeah absolutely max thing so maximum element in the this is how i remember and this is how i map these all things in my mind no sir code part of the presentation yeah sure see the code part okay one two three okay i hope you have taken the screenshot okay now the next part is we would find the next greater element on left side okay next greater element of the left side most welcome okay so what we do is suppose the next little element of one is three so it is three answer for three it is four so it is four for two it is four and four four there is no next greater element on the left right hand side so sorry this would be right hand side for you it would be right hand side for me it is left hand side so for this side it would be minus one so so this class is useful for technical text yeah this class is very useful so in previous question can we use maxip and pop k times so if you use max heap and pop k times no no you can't pop k times see if you insert all those elements and then you pop n minus so n minus k n minus k would be the element that is not needed so if you pop all the elements that is not needed okay that's absolutely fine but inserting all those elements in the priority queue would take log n so skip elements say there are n elements and inserting them would cost a login operation so basically you are again taking hold of n log and approach okay that is why that is not an improvement but basically what you can do is you can simply sort if you want to use this idea but if you are using this idea you can see that the value the number of elements in the priority queue never exceeds k okay that is why the cost of those collectively is k log k okay am i clear richie or not just tell me that yeah this class is very useful for uh so just try to see we have a core subject to cover for a technical test okay then we have other things also so try to minimize the amount of mugging up in the dsa part okay yeah that's absolutely fine okay so in this problem what you need to do is you need to start looking on the right hand side and suppose suppose it is 1 then 0 then minus 1 then 2. so what we do is we start from 1 and this is not greater than 1 this is not greater than one this is greater than one so the next element we find when we start going towards the right hand side the first element we get that is greater than the current element we say that for this element this is the next greater element quickly send me a one in the chat if you have understood this question okay okay fair enough this is what you need to do so let's do the dry run of one three two four so we have one three 2 and 4 so for 1 we come across this this is this yes 3 is greater than 1 so what we say is we say for 1 an external element is 3 then we come across 3 three three three two is greater two is less than three so this is not the case then four four is greater than three so we can say that for three the next vector element is four then from two we start traversing start traversing and we find the first element 4 that is greater than 2 so for 2 the next element is 4 itself then we come across 4 we start moving on this side there is no elements to compare if there is no elements to compare it is mentioned in the question that we need to report -1 that is how the answer to this is 3 4 4 and minus 1. thanks a lot pile thanks a lot darshan thanks a lot ronak okay only this much people is following up am i so boring okay so now the first brute force approach okay the brute force approach to this is and that for each element each element we try to find the next greater element next greater element how do we do that i would just simply show you okay so what can be done is we can have a for loop and i is equals to zero i is less than n and i plus plus okay this should be i is less than n okay and then we would have a counter for j itself for end j is equal to end j is equals to i plus 1 j is less than n and i plus plus then if a of j is greater than a of i we would just say that the next greater element nge of particular i is equal to a of j and if we are not able to find we would initialize everything we would initialize every value of ng with minus 1 so even after iterating the whole value if the value of nge of i is equal to equal to minus 1 then we would say that yes it would remain minus okay that is how we can do it okay sridhara tell me the point where you are not able to understand okay so now this is the brute force approach so for each element so for one so far suppose i am standing at the index 0 so i need to iterate over the whole array so for one element for one element i am doing n operation so 1 into n and n into n multiplying n on both side then we have for n element we would do n square operation so the time complexity of this approach is big o of n square okay can we improve over this yes we can definitely improve over this how can we okay let's take the same array i one three two four okay what i see is what i say is we would find a data structure okay we would just name it as bs as of now we don't know which data structure we are using just we would use a data structure and then what are the things we do do if d s is empty if ds is empty then we would insert the current element so we would insert the current element if the ds is not empty if the ds is not empty okay and if not what we would do is we would keep keep popping out elements less than current and for all these all elements for all these all elements this is the next rotor element and then we would insert the current if this is not the case okay if this is not the case we would just insert the current am i clear till this point or not okay how this is working i would show you okay don't worry about this so we have one three two four this is what we had so we have this one three two and four so initially the data structure is empty so we would insert one then we have three now so three is less than the last element less than the last element so we would take out this one and we would say for one the next greater element is three now this the particular data structure is empty so we would insert three next we come across two two as less than the last inserted element so we would insert that next we have 4 so far 4 is greater than the last inserted element so we would remove this 2 and we would say for 2 the next letter element is 4 then we have 3 so for 3 is also less than 4 so we would remove this 3 and we would say for 3 also the next letter element is 4 then we have 4 itself that would remain so all the elements that remain they have no next greater element so now am i clear with this or not why this is working what is the algorithm then we would see how to decide upon the data structure again and trust me if you reply quickly i would just need five more minutes just five more minutes and i would leave you don't worry i won't bother you trust me i won't disturb you that much quickly reply with the one in the chat quickly quickly okay so we have more people telling me one itself so now let's get back to what we have decided okay so let's get back so to do this what are the things we need okay what are the things we need let's discuss that also so we would need okay we would need a data structure with these all requirements so i would just write requirements these are the requirements what are the requirements the first requirement is we need to insert elements so we need a data structure where we can insert elements so if you don't mind can you explain it again why would i mind this is my kind you're not bothering yeah okay that's that thank you for okay so i would just show you again okay i would tell you redo okay this is what we would do okay so so this is what we would do last inserted element the current element so we would keep popping keep popping elements in the current element okay now now what we would do is we would start the iteration one three two four one three two four so let's do so first the data structure is empty we would insert this then we have three three is greater than the last inserted element on the data structure so we would say that for 1 the next letter element is 3 and we would remove that next we have 3 the data structure is empty so we would insert that next we have 2 that is less than the last inserted element so we would simply insert it then we have four four is greater than the last inserted element so we would say that for two the next letter element is four and we would remove this still we have the next little element greater than the last current element so last element for three the next element is 4 now we would insert 4 so for all the elements that remain we can say that they don't have an exterior element so can am i clear through the okay fair enough so let's move forward okay so what can you tell us what basic approach you're following to for selected data structure for a question so see we have data structures and algorithm the whole engineering career of cs and it is dependent on this okay so we can safely say that first we need to design the algorithms then according to the algorithms we need to write out the requirements this is what i am doing i am trying to list out the requirements and then i should initially beforehand know that which data structure is efficient in doing which operation my which friend is able to play good football my witch friend is able to do good programming my witch friend is able to entice girls okay these all things okay this is the proper way of doing that rigid am i clear to you or not so the first requirement is that we should be able to insert elements the next is we should insert elements to the back so insert at back insert at back the next thing is we should access the last inserted element so access to last inserted element inserted element itself the next is the third point is what is the third point the third point is we should we can remove last inserted elements remove last inserted element this is what we need okay so now first we can insert elements from the back access to the last inserted element and remove the last inserted element last time also i never told you the data structure that i i need to use this time also arijit especially from you and others tell me which data structure is very efficient in doing all this operation insert at the back access to the last inserted element and also removal of the last inserted element tell me which data structure should we select tell me quickly tell me and then we would quickly move forward but quickly tell me quickly quickly quickly stack ayush agarwal no i want the reply for someone else because ayushvagarwal he was the last last time also he was the person ronna thanks a lot okay thanks a lot thanks a lot okay arijit kumar pandav now you know how i'm doing this thanks a lot okay so we should be using stack itself stack follows a thing known as last in first term so whenever you are told in the interview that which data structure follows the last in first out the first thing that should pop in our mind is stack itself okay one three two four so let us quote this in the sublime text okay so we have the simple thing we have the stack of end and we would name it as sp and then i would give you one wonderful trust me i would give you a very wonderful idea okay of data structure this time trust me i won't wait you okay so in a dash is equal to 1 3 1 and 3 and 2 and 4 itself okay and we have the size equals to 4 okay then what we do is we start the iteration so for this we would have i is equals to 0 i is less than n and then i plus plus okay so now what we do is we would first check if the stack is empty so if the stack is empty we would push that in the element itself a of i if the stack is not empty there might be two condition so while the stack is not empty so while the stack is not empty and and and the last element st dot top element is less than a of i the current element so we would say c out st dot top elements next greater element is the current element itself after i am done with this and then we would pop this also st.pop and then we would insert this st dot push the current element and then we can safely say that while the stack is not empty the remaining elements for all the remaining elements we can say that this is happening st tops next greater element is minus now let me just quickly check so we have one three two four we have sizes four and if the stack is empty we are pushing the current element if the stack is not empty we are checking if the stack is not empty and we are taking hold of the top element okay it if it is less than the current element we would simply pop and say that for this element the next greater element is this and we are popping that so let us print that okay so let us do an end line 2 because that is just disrupting the answer just a quick idea if you are into competitive programming remember to use this instead of end line okay even if you are giving machine press okay so for one the next order element is three so for two the next letter element is four and for three the next state element is four and four four the negative element is minus one okay fair enough okay i should be clear with this now a pro tip to this okay a pro tip is a pro tip is use so in stack there is some problem with stack if we are using element if we are using stack then we can only access last element we can only access the last inserted element but not other than that there is no indexing kind of thing so if i tell you that we have an improved stack in the stl itself what i say is instead of stack start using something known as vector y vector because accessing the last element of the vector and popping the last element of the vector both are big o of 1. okay so basically let us now try to think about so let us see the time complexity of this approach too okay so now let us do the next scatter so now let us see so for this we are initializing initializing and all we take big off constant time we are pushing pushing an element in the stack is taking big of one and this every element is getting transferred out once so basically all together we are doing big o of n that is why the time complexity is bigger tell me if you have any problem in the time complexity i would explain you why this is big of 1 so what i say is use vector over stack so now let us solve this problem using vector itself okay so what we can do is we can have a vector okay and there is no top kind of thing while vector is if the vector is empty we would insert element and this should be push back okay this would be pushed back and instead of top i would have something known as back okay then this one would also be back and if you want to remove all the occurrences at once then use command d or ctrl d okay and this would be pop back thing okay then this would also be what back and this would also be popped back okay so let me just see if i made any mistake or not yes i made a mistake so while the stack is empty we would push back if the stack is not empty we would see the back element and then we would pop back the element yes this is fine okay so this should be okay we are pushing somewhere yeah so we have push back see this is again working the same so if you are giving test online or if you are working on an online judge you can use vector where you can even access the indices to so do trick so let's sum up all the things so summing up all the things that we have done till now is the first one where we know a question the largest k element it is a very famous question it has appeared in which watch companies let me tell you the company tags are amazon google microsoft samsung and walmart the next question we discussed was the question of flipkart amazon microsoft. i took the most famous two questions the next thing which we did was we took up the courage to have the requirements and then decide a data structure and no data structure was revealed by me in the whole stream it was revealed by one of you between you yourself your brother or your sister revealed to you that which data structure should be used the next thing is that we implemented it live then we learned two tricks what are the two tricks that using using minip we can convert it to max heap and from max it we can convert it to min heap without the initial without changing the initialization just by multiplying with minus 1 before inserting and multiplying with minus one after taking out this is the thing the third the third thing was the third thing was using vector instead of stack so can i have a quick thank you and then i would just leave so now it's an open forum i have five minutes to spare you can ask me anything related to your placements or something okay so now we have the ask me anything session sorry ask me anything okay so now you can ask me anything you want okay does vector take one one for popping in java as well but as far as i know there is no vector there is array list okay and it has been a long time that i have been into java so i'm not that much specific that which data structure is using what the next thing was thank you thank you thanks a lot most welcome richie most welcome most welcome shamal okay by the way this is my linkedin username so i receive i am receiving no placement questions as of now so i think that i don't need to wait very long i think no question because no one is that why would be anyone okay so this is my linkedin username you can send me a connect connection request if you want okay so i see no more doubts coming in still we would wait for the next 30 minutes and then we would we would leave itself okay okay okay okay so that's it for today thank you and have a nice day take proper rest but remember to be consistent because this programming thing is all about consistency it's not about doing 10 questions in one day but it's about doing one question each day or two more than two question i'm a non-career student what should be my preparation plan for placements okay non-career students what do you mean by non-career students so the preparation plan remains the same you can start off with the basics then you can move to start solving school level question then easy level question medium level question now there is one more thing you don't need to learn all the data structures beforehand rather what you can do is you can take up a question now there are two probabilities either you already know that thing that is that needs at solving that question but you are not able to use that that means you need the proper practice on that particular topic the next is that you didn't knew this term if you didn't knew this topic that means that you need to learn that topic do some practice then again come back to this question itself when i'm good to learn dp you you are good to learn dp when you are good with recursion very good with recursion i'm don't like coding i'm interested in networks where do i want to start if you are into networks what you can do is you can talk to some people who are very good in the industry of networks because i can say that i am little bit good enough in coding but in indus so you should talk about from the best if you should take flavor from the best okay so i'm in the fifth semester yeah i'm also in my sixth semester okay non-career means i have uh don't have sixty percent and two that's absolutely fine i don't think many companies have removed that criteria thing of 60 percent what a data structure must know list for solving many questions at least approaching them so when you need to know set you need to know multiset you need to know you need to know priority queue you need to know array you need to know you need to know queue you need to know stack and all you need to link list so can data structures alone give placement and job no data structures and placement are a pair of shoes okay if you are using one pair that if you are using one pair one shoe not a pair of it it is useless so without algorithm data structure is useless and without data structures algorithm is useless okay but with both they are a very good thing okay okay i see no more doubts coming in okay we still have a minute left okay okay okay we have a lot of people we have 50 people to be honest okay so that's great okay so how to prepare for placement this is already answered okay okay so that's it for today thank you and have a nice day it was very nice interacting with you and the interaction from your side is was very good to be honest okay but just be consistent in this game thank you
Original Description
Are you Carnival ready?
Because we have got you covered for one full week of fun-filled coding activities and insightful webinars where you will meet the best of the industry giants.
Not just this, you will also receive hefty discounts on all our courses, get introduced to hundreds of job opportunities and get chances to win exciting rewards!
Check out: https://practice.geeksforgeeks.org/geeks-summer-carnival-2021
In an interview, the trickiest part is to chose the right data structure to solve the question. In today's event, Sidhart Hazra (Mentor at GeeksForGeeks) will discuss the strategies and tricks to recognize which data structure to use in a question.
And don't forget to check out one of our most renowned DSA-Self Paced Course: https://practice.geeksforgeeks.org/courses/dsa-self-paced
#datastructure #dsa #interviewprep
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from GeeksforGeeks · GeeksforGeeks · 18 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
▶
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How I got into Walmart | Shailesh Sharma
GeeksforGeeks
Upgrade yourself In 29 Days | GeeksforGeeks
GeeksforGeeks
Learn AWS Fundamentals For Free
GeeksforGeeks
Conversation With Young Achievers | Meet the winners of Bi-Wizard Coding Contest | GeeksforGeeks
GeeksforGeeks
Meet The Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
Interview Prep Strategies | PayPal
GeeksforGeeks
OLX Interview Preparation Strategies | Hukam Singh
GeeksforGeeks
Meet Some More Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Microsoft Azure For Absolute Beginners
GeeksforGeeks
Python for Data Science | Data Science Master Bootcamp | Arpit Jain
GeeksforGeeks
Getting Started with Data Analysis | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
How to prepare theory subjects for SDE interviews | Geeks Summer Carnival 2022
GeeksforGeeks
Get Your Tickets To The Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
TED Talk Data Analysis Project | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
How I Secured AIR 9 in GATE'22 | Tushar
GeeksforGeeks
Learn Java Backend Development | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
How to Recognize which Data Structure to use in a question | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
Learn Data Structures and Algorithms | GeeksforGeeks
GeeksforGeeks
Interview experience at Flipkart | GeeksforGeeks
GeeksforGeeks
Lets Prepare for GATE'23 the Right Way | Sakshi Singhal | GeekSummerCarnival
GeeksforGeeks
Highest Paying Jobs in 2022 | Ishan Sharma | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival 2022 | 5th April- 11th April | GeeksforGeeks
GeeksforGeeks
Preparing for SDE interviews | Soham Mukherjee | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Full Stack Development with React & Node | Utkarsh Malik | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
Introduction to Open Source and Roadmap to GSOC 2022 | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Web Scraping in Action | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Getting Hired at BITCS via GfG Job Portal | Get Hired With GeeksforGeeks
GeeksforGeeks
How to build a faster landing Page | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival | 5th To 11th April, 2022 | GeeksforGeeks
GeeksforGeeks
How to get ideas for Startup | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Journey from Tier 3 to JusPay | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Dispelling Myths and Pre conceptions of Programming Languages
GeeksforGeeks
Must Do System Design Questions
GeeksforGeeks
Understanding Sorting Techniques in an hour | Keerti Purswani | Geeks Summer Carnival
GeeksforGeeks
Get Hired at NEC | Job-A-Thon 8
GeeksforGeeks
Journey from Tier 3 college to Microsoft | GeeksforGeeks
GeeksforGeeks
Get Hired with GeeksforGeeks at SuperK | Job A Thon 8
GeeksforGeeks
GeeksforGeeks: Redesigned
GeeksforGeeks
From Tier 3 to cracking multiple interviews | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Youtube Data Analysis | Ashish Jangra | GeeksforGeeks
GeeksforGeeks
DSA Self-Paced Course Preview | Sandeep Jain | GeeksforGeeks
GeeksforGeeks
GATE Live Classes | Prepare for GATE CS 2023 | GeeksforGeeks
GeeksforGeeks
Journey from JIIT to Adobe
GeeksforGeeks
Life Is Unfair Ft. Shonty badmash | LIVE Discord Session | A GeeksforGeeks Exclusive
GeeksforGeeks
Interview Experience at Google | Tech Dose
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Interview Experience @ Amazon | GeeksforGeeks
GeeksforGeeks
My journey through the tech world from India to US | Vidushi | GeeksforGeeks
GeeksforGeeks
Complete Interview Preparation Course | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Getting Hired at FiftyFive Technologies | Job-a-thon 9.0
GeeksforGeeks
GFG Karlo, Ho Jayega | GeeksforGeeks ft. Khaleel Ahmed
GeeksforGeeks
How I got job offers from 2 big companies : Arcesium & Microsoft | GeeksforGeeks
GeeksforGeeks
LINUX for Beginners | GFG x Itversity
GeeksforGeeks
My interview experience at Walmart | GeeksforGeeks
GeeksforGeeks
Get Hired at Speckyfox
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
More on: Algorithm Basics
View skill →Related Reads
📰
📰
📰
📰
The Everyday Backend Engineer: Step 10 — The Observer Pattern
Dev.to · Manoj Khatri
ArborDb: a Rust document store where reading one field doesn't get slower as the record grows
Dev.to · Frédéric Meyer
The 2026 World Cup: A Stress Test For Enterprise Intelligence
Forbes Innovation
Why Interoperability Can Be A Tough Sell In Manufacturing
Forbes Innovation
🎓
Tutor Explanation
DeepCamp AI