How to solve problems on Leetcode/HackerRank to prepare for a tech interview

This article helps you with how to prepare for a technical interview

how to solve problems to prepare for a tech interview

Have you ever asked yourself this question? I think so; that's the first question at the start of your journey. Although the process often looks like a forest in which it's easy to get lost. I give you the plan and method of how to prepare. By following the instructions, you're guaranteed to get results.

My plan combines approaches from "Cracking the coding interview" and leetcoder's recommendation. This guide builds on foundational knowledge covered in my how to learn algorithms article.

My Interview Preparation Experience

After completing 200+ LeetCode problems and securing offers from tech companies, I've refined this approach through real interview experiences. This isn't theoretical advice—it's a battle-tested methodology.

Track of your progress

Before solving any problems on LeetCode/Hackerrank, think about how you keep track of your progress. Create yourself a progress sheet with properties: problem title or link, date, topics, attempts. You can create an excel sheet or use my Notion Template for it (link).

Understand problem

It's not a simple step. You have to understand the problem. Read the task description carefully: your main goal is to understand all possible cases. Think about all possible examples. Ask yourself the following questions:

  1. What data are available?
  2. What kind of relationships do the parameters have?
  3. Do you need immutable or mutable data?

High-level algorithm

Create a high-level solution as soon as possible. Create a naive algorithm with a lot of issues with optimization; it's not a big deal! But each time for every solution - explain what the space and time complexity is.

Review and Optimize

The next step is to review your algorithm and think about what you can improve. Find bottlenecks inside your algorithm and try to resolve them. Also, remember to clean up your code from unnecessary actions such as unnecessary duplications, useless calculations.

Optimization strategies I've learned:

Test yourself

For me, the last but not least step - testing. Be careful and check all cases from the second step. Start with conceptual tests and only then move on to special cases.

Testing methodology from my practice:

  1. Edge cases: Empty inputs, single elements, maximum constraints
  2. Normal cases: Typical inputs that match the problem description
  3. Boundary cases: Minimum/maximum values, off-by-one scenarios
  4. Performance testing: Large inputs to verify time complexity

Advanced Problem-Solving Patterns

Through solving 200+ problems, I've identified key patterns that appear repeatedly:

Pattern Recognition

  • Hash Map problems: O(1) lookups for frequency counting
  • Trie structures: Prefix matching and autocomplete
  • Two pointers: Array problems with sorted input or target sums

Interview-Specific Tips

  1. Think out loud: Explain your reasoning process
  2. Start simple: Get a working solution before optimizing
  3. Ask questions: Clarify constraints and edge cases
  4. Test thoroughly: Walk through examples with your solution

Building Consistent Practice

Weekly schedule that worked for me:

  • Monday-Wednesday: Focus on one algorithm pattern (e.g., binary search)
  • Thursday-Friday: Mixed problems from different topics
  • Weekend: Review mistakes and study optimal solutions

For foundational knowledge, start with my complete learning roadmap that covers prerequisite data structures and algorithms.

Further Reading