DSA Preparation - The Ultimate Guide to Crack DSA Interviews

Want to crack DSA coding interviews at Amazon or MAANG? Look no further as this guide contains all the tips to help you prepare data structures and algorithms.

Mentor

Blog

Are you tired of spending hours and hours practising DSA for interviews but still feeling unprepared?

Do you freeze up when asked a complex coding question? If so, you’re not alone.

I was there once so I know how frustrating it is to give your all and the outcome is still not in your favour.

DSA preparation takes time and only with the right strategy, you can master it.

Cracking your DSA interviews can become the difference between landing your dream job and still searching for it.

In this comprehensive guide, I have discussed the best way to learn data structures and algorithms for interviews.

You’ll also get a rundown of what the companies are expecting and my own Amazon interview experience.

I have covered the following topics:

  • Why is it important to learn DSA?
    • Applications of Data Structures and Algorithms
      • Why is DSA asked, why not other tech stacks?
        • Data Structures and Algorithms Topics for Interviews
          • How to prepare for DSA interviews?
            • How to answer data structures and algorithms questions in an interview?
              • What do the companies expect from a candidate during coding interviews?
                • What strategy to follow for a Data Structures and Algorithms Coding Interview?
                  • How to apply for interviews at MAANG or other top companies?
                    • How did I crack my Amazon interview?

                      Before diving into DSA preparation and cracking those tricky coding interviews, let’s read a little about its importance and applications.

                      Why is it important to learn DSA?

                      We use data structures and algorithms in our day-to-day life in many ways. 

                      It also plays a huge role in implementing many underlying software components where optimisation is heavily required. 

                      For example, it just takes seconds to log in and access your Facebook account after entering your username and password.

                      When you enter your credentials, a lot of process goes on in the backend to validate your credentials along with those of other users. 

                      Thanks to optimisation and time complexity in data structures and algorithms, the log-in process only takes seconds.

                      Applications of Data Structures and Algorithms

                      You may not be aware of this but most of the underlying softwares that you are using in your day-to-day life use data structures and algorithms. 

                      Here are some common applications of DSA in real life.

                      ▶️ Stack (Undo Operation)

                      Stack is a data structure and algorithm that follows the LIFO (Last in First out) method

                      Let's say, you want to record some stuff and have opened a Notepad or any text editor.

                      When you type in, the text is added on top of a stack that records it. 

                      It allows you to undo your written text and go to your last recent action in case of errors.

                      ▶️ Queue (Image deletion and waiting lists)

                      Queue works in the mechanism of FIFO (First in First out)

                      Suppose, you are booking a ticket in the IRCTC portal, and if your ticket goes to the waiting list, your number will be pushed into a queue.

                      Now, whoever comes in first will go out first.  

                      So the person who is in front of the waiting list will be pushed ahead in the queue in case of cancellations or any seat availability.

                      ▶️ LinkedLists (Browser’s next and previous tab)

                      These are linear data structures that are made of a sequence of nodes.

                      When you open a browser tab, at the top, you can see a refresh option along with the backward and forward arrows. 

                      The back and forth between pages happens because of linked lists data structures.

                      When you click on the previous arrow, you are redirected to the previous page based on the data stored in the linked list node as the previous URL.

                      ▶️ Graphs (Maps, Social Media) 

                      These are non-linear data structures that consist of a set of nodes (vertices) that are connected by edges.

                      Google Maps in apps like Uber, Olas, Zomato, etc. uses graph data structures to optimise and find the shortest path to a particular destination.

                      So, whenever you are searching for a destination it will calculate the best route to take.

                      For social media platforms like Facebook, you can identify your mutual friends and connections based on DFS (Depth-First Search) and BFS (Breadth-First Search)  that use graphs.

                      ▶️ Trees (File Hierarchy)

                      Trees are also non-linear data structures that consist of nodes connected by edges in a hierarchy

                      These help in maintaining the file hierarchy and database indexing.

                      You can store folders inside folders with the help of tree data structures and algorithms.

                      Similarly, you can store and retrieve data efficiently with trees.

                      Why is DSA asked in interviews, why not other tech stacks?

                      In a lot of product companies, there is no particular tech stack that they use. 

                      It differs from team to team.

                      In Amazon, my team uses Java but the other teams use Python and TypeScript.

                      This makes it challenging to evaluate a candidate. 

                      Let's say you are good at React but the company you are interviewing at is not using it, then it becomes difficult to make a sound hiring decision. 

                      Most companies are looking for two things,

                      • How efficient are you in solving the problem?
                        • How good are you at communication?

                          Learning a language or framework does not take much time.

                          But, developing the thought process and how to create an efficient piece of code takes time. 

                          To overcome this challenge, data structures and algorithms have become a universal medium. 

                          DSA interviews help companies evaluate candidates' problem-solving skills and communication skills.

                          Data Structures and Algorithms Topics for Interviews

                          DSA Preparation Topics for Interview

                          It is important here to understand that you have to learn the DSA topics in a particular chronology

                          Each topic builds upon the previous one and learning them sequentially can ensure that you can solve complex problems. 

                          For example, without knowing about recursion and backtracking, you will not be able to solve dynamic programming (DP) problems. 

                          If you are confused as to what chronology to follow for your DSA interview preparation, connect with me.

                          How to prepare and master data structures and algorithms for interviews?

                          Let me tell you the best way to learn DSA. 

                          This is the strategy that I followed for my DSA interview preparation.

                          🟢 Start basic coding

                          Data structures and algorithms are built on fundamental programming principles. 

                          So until and unless you have a solid foundation in basic coding, it's hard to understand DSA.

                          Start by learning a programming language of your choice and slowly and gradually build your coding skills.

                          🟢 Move on to DSA, start out with easy questions

                          After that, start understanding the basic concepts of DSA and practise easy questions.

                          This will also help build your confidence.

                          Solve simple questions like finding the maximum and minimum value in an array or reversing an array

                          🟢 Move on to medium questions

                          Now, you can move a ladder up and start solving medium questions. 

                          They’ll be slightly more complex and will require a more in-depth understanding of DSA concepts.

                          Examples of medium questions include finding the second largest number in an array or sorting an array using merge sort.

                          You might be thinking, how many questions are enough?

                          I get this asked a lot and the simple answer is that there is no fixed number.

                          The best way to learn data structures and algorithms is to strengthen the basic concepts and solve a wide range of questions.

                          The key to preparing for DSA interview is to practise consistently.

                          🟢 Move to slightly advanced topics like Graphs, Dynamic Programming

                          Once you have solved a good number of medium-level questions, you can start practising advanced topics like graphs and dynamic programming.

                          Both these DSA topics for interviews are important for companies that work on complex software systems.

                          🟢 Do random questions

                          Doing random questions helps build your thought process on what parameters and algorithms should be used for a particular question. 

                          It forces you to think critically to solve them.

                          Consider yourself ready only when you can solve random DSA problems.

                          🟢 Do mock interviews with industry experts

                          A lot of times, even if you are aware of the DSA topics you want to master, it's tough to create a preparation strategy. 

                          This is where industry experts can help you. They can create a DSA roadmap for beginners like you.

                          There are a lot of professionals who are ready to lend a helping hand to help you prepare and crack your DSA interviews.

                          All you have to do is ask.

                          With their valuable insights and feedback, you can save a lot of time and practise in a real interview simulation.

                          To make my mentees ready for the Amazon SDE interview process or any other MAANG interviews, I conduct mock interviews under my long-term mentorship program at Preplaced. 

                          In case, you also want to practise mock interviews, book a 1:1 session with me.

                          What strategy to follow for Data Structures and Algorithms Coding Interviews? 

                          ☑️ Look for company-specific topics: 

                          You need to choose a list of DSA topics for DSA interview preparation. 

                          First, sort out the company-specific topics and solve questions for each of those sorted topics. 

                          Many companies have their own preferred topics that they ask questions from. 

                          For example, at Amazon, the recruiters ask DSA questions from linkedlists and trees.

                          By knowing this, you can focus your preparation and increase your chances of success. 

                          You can find the questions and company-specific DSA topics on various websites such as Glassdoor, GeeksforGeeks, etc. 

                          ☑️ Go through all the basic concepts

                          Learning DSA is not all about memorising the data structures and algorithms but understanding them.

                          • What does it mean?
                            • Why is it important?
                              • How does it work?
                                • Where to use it?

                                  And then check the standard questions of the DSA topics and try to solve them.

                                  Hence, it's a good practice to know all the basic concepts of DSA. 

                                  And focus more on those that are preferred by your target companies. 

                                  Sometimes the interviews can also ask for the implementation of basics such as implementing your own sorting algorithm. 

                                  If you cannot do that then it will be hard to move ahead in the further interview rounds.

                                  ☑️ Practice on a platform that works for you

                                  There are a lot of platforms to choose from such as LeetCode, GeeksforGeeks, HackerRank, etc.

                                  Choose a coding platform that suits you and start practising.

                                  ☑️ Practise time complexities and space complexities and their derivations

                                  Time complexity is really important if you want to crack DSA interviews at any MAANG or top tech companies. 

                                  Time complexity is the amount of time the program will be taking to execute the given action.

                                  It is measured in seconds and minutes. 

                                  For example, if a program takes 10.8 seconds to execute and there is another way to write the code that takes 10 seconds, you will obviously choose the most optimised one for your solution. 

                                  This also helps to understand why one algorithm is performing better than the other so that you can trade off on which one to choose.

                                  Space complexity helps you to understand how much space your program uses.

                                  If your program declares an array or stores something in that array, that becomes the space complexity of this program or a particular code or snippet.

                                  Knowing both time and space complexities helps you optimise your code and make it more efficient.

                                  Most of the time it is mandatory to explain the time and space complexity of the solution to the interviewer. 

                                  Even though the interviewer may not ask for it, deriving and explaining it will give you an extra edge over others.

                                  It will also show how aware you are of the problem and will create a good impression.

                                  How to answer data structures and algorithms questions in an interview?

                                  🎯 Brute force to optimised approach

                                  If you are asked in the interview a question that you have solved before and know the answer to, don't rush to derive it quickly.

                                  It won't give the interviewer the chance to assess your thought process.

                                  In this case, either you can let the interviewer know or you can solve it in a brute force to optimise approach. 

                                  Now, what is brute force?

                                  It is an algorithmic technique whose time complexity and space complexity is a lot more than the optimised solution.

                                  This shows that you understand the problem statement and can come up with an efficient solution.

                                  🎯 Explain your approach clearly

                                  Take the interviewer through your thought process. 

                                  Explain the reason why you’ve selected a particular algorithm to solve the problem.

                                  Let them know the complexity of the solution, and provide an example if necessary.

                                  This can also help the interviewer give you any clarification if needed. 

                                  🎯 Think out loudly

                                  As you are solving the coding problems, speak out loud and explain your code.

                                  Don’t worry if it's wrong or inefficient.

                                  Describe the steps taken and their importance.

                                  It helps the interviewer to evaluate your problem-solving skills.

                                  🎯 Don’t assume anything, ask clarification questions

                                  Don’t hesitate to clarify questions if you are unsure.

                                  The interviewer will have no problem giving you some insight and clarifying your doubts.

                                  Also, don’t make any assumptions about the problem, or the input/output requirements. 

                                  By asking the interviewer, you can also be aware of any edge cases or special conditions.

                                  The more clear you are, the fewer chances of making any mistakes.

                                  What do the companies expect from a candidate during coding interviews?

                                  As I mentioned before, companies use data structures and algorithms as a common medium to evaluate candidates.

                                  In these interviews, they look for 3 key skills:

                                  1. A good problem solver

                                  The recruiters are looking for someone who can analyse a problem and identify potential solutions and select the one most apt.

                                  2. A clear communicator

                                  How good you are at explaining your thought process to the interviewer is highly valued.

                                  This is crucial as you’ll be working in a team and effectively communicating can ensure that everyone is on the same page.

                                  3. Someone who can write quality code

                                  By this I mean, writing code using good coding conventions that are easy to read and scalable.

                                  Let's say you want to calculate the number of balls in a box or based on some mathematical logic. 

                                  If you name your variable as ‘n’ it will not be a good convention for writing the code. 

                                  A variable name should convey the whole story.

                                  If you are using the ‘number of balls’ as your variable, it becomes descriptive and makes sense. 

                                  Hence, for DSA preparation, practise these three things to demonstrate them in the coding rounds.

                                  How to apply for interviews at MAANG or other top companies?

                                  👉 Build your network on LinkedIn

                                  I am sure you already know the importance of a LinkedIn profile.

                                  Keep it updated and make it relevant to the role you want to apply to.

                                  It's a great way to get noticed by potential recruiters.

                                  Connect and engage with individuals in your desired industry. This can also help you with referrals.

                                  👉 Ask for referrals

                                  Speaking of referrals, don’t be afraid to ask them. 

                                  Let your connections know that you are looking for a new opportunity. 

                                  But don't be random.

                                  You cannot just ask someone to refer you without explaining why they should do this.

                                  Tell them why you are the perfect fit for the role and then share your resume.

                                  👉 Have frequent visits to the career pages of various companies

                                  Another great way to stay up to date with the openings is to regularly visit the career pages of your target companies. 

                                  Many companies regularly update their job listings, so it's important to check back often to see if there are any new positions that interest you. 

                                  This is especially important for companies like MAANG which receive a lot of applications.

                                  👉 Enable notifications on the career pages for your desired roles

                                  Finally, enable the alerts on the company pages by signing up. 

                                  You can filter your desired roles along with locations and turn on the notifications.

                                  This way you won’t miss the update and will be among the first ones to know.

                                  How did I crack my Amazon interview?

                                  I applied at Amazon as an SDE intern which later got converted into a full-time job based on my performance. 

                                  As an intern, I needed to go through one written test and two rounds of interviews completely based on data structures and algorithms.

                                  I was both excited and nervous to secure a position at Amazon and showcase my skills. 

                                  I spent a significant amount of time practising coding problems which helped me build my approach for the questions that could potentially come up in the interviews.

                                  By the time the interviews rolled around, I had a good grasp of data structures and algorithms.

                                  On the day of the interview, I was fully prepared to tackle any coding problem that’ll come my way.

                                  I was able to clearly explain my thought process and provide efficient solutions to the problems given. 💫

                                  My selection was directly proportional to the efforts I made. I feel like even luck favours those who are prepared. 

                                  Preparing and practising beforehand is key to success in the interview process. 

                                  And what I can do for you is help you prepare and crack your interviews at MAANG. 

                                  Before joining Amazon, I was a DSA mentor and have helped over 100 students master data structures and algorithms.

                                  Be it mock interviews, resume reviews, interview planning or DSA preparation strategies, I can help you with both technical and non-technical aspects.

                                  I am just a click away.

                                  Ready to take the next step? 

                                  Looking forward to helping you reach your career goals so that you can bag your dream job. 🚀

                                  Recommended Reading: Decoding Amazon AWS SDE Interview - Process and Preparation