Data Structures and Algorithm are one of the most important things in Technology and are asked in almost all Interviews be it for Full stack developers, DevOps, or any other role. It is considered a metric to judge your problem-solving skills and generally, if you are good at it you are a good problem solver. After Understanding "why" is it important let's dive into "how" to learn DSA.
Pick a Programming Language
DSA is not just about theory, you should pick up a language you are comfortable with and are reasonably good at. Picking the right tool for the job is also a skill you need to master.
Learning DSA - 8 Step Process
Step 1 - Give yourself Time
Mastering anything requires patience, discipline, and effort. Do not get frustrated if you are not able to solve the problem on your first try and start looking for answers directly, instead give yourself an hour to solve a problem.
Tip - Rome wasn't built in a day, great things take time.
Step 2 - Efficiency
You should not aim for the most efficient solution on the first try. Getting the working solution and then working your way from there is always the better approach.
Step 3 - Fundamentals
Be strong in your fundamentals, make sure that you understand the working behind a certain algorithm or idea before implementing it yourself. A good grasp of your fundamentals will help you in your confidence when you start solving questions.
Step 4 - Use Pen and Paper
Use pen and paper to write down the given statement in problem, problem to solve in bullet points then start working from there.
Visualize your solution using a flow diagram before writing a single line of code. This will act as your roadmap when you start coding your solution.
Step 5 - Dry run your code
Using the flow diagram you created, take a simple case and try to dry run your code against it. You might have to make some changes or your approach might not work at all. It is okay, focus on your learning and do not compare yourself with others.
Failures and setbacks are a part of the learning process, your aim should be to be better than yesterday's you.
Step 6 - Take breaks
Taking breaks in between is important to let your brain process the information that you learned and assimilate it without feeling overwhelmed.
You can follow the Pomodoro technique for this or take a 5-10 minute break every 1 hour.
Step 7 - Keeping moving
If you get stuck with a problem or a topic after spending a considerable amount of time on it. You can skip it for the time being and revisit it later. Revisiting a problem later allows you to look at it from a fresh perspective while making progress and not stopping.
Step 8 - Do not think of Interviews while studying
Working with a goal in mind is a good thing but only thinking about the interview process while studying does not help. Focus on your learning and the results will follow which are you doing well in your interviews.
Now, once you have completed your preparation for DSA and are confident. Some tips on Interview preparation.
Interview preparation - 4 Step Process
Step 1 - Time yourself
Now that you are confident in your preparation, it's time to simulate the test environment by timing your solving time. Use a timer while solving the question.
One approach which I use and suggest would be to try explaining your answer as if you would explain it to an Interviewer. Use a camera or mirror to simulate this and talk yourself through the solution.
Step 2 - Maintain a list
You are still in your learning stage, there is a possibility that some questions take longer than expected. Keep a list of all the questions you have solved with the time it took.
This approach has two benefits, first, you get to see your progress, and second, you have a list of questions to refer to later.
Step 3 - Identify weak topics
Using the list created, sort and identify the topics which are taking you a long time to solve. Re-learn the approach to solving the question and strength the fundamentals.
Step 4 - Reattempt
After going through the fundamentals once again, try to solve the questions once more. Going through the questions again will strengthen the neuron connection made during learning.
Following the approach with discipline and dedication and you will succeed!.
The problem ahead of you is never greater than the strength within you.
All the best!