Skip to content

ChunhThanhDe/Leetcode-Top-Interview

Repository files navigation

Leetcode Top Interview 🎯

This repository contains solutions to the Leetcode Top Interview 150 problems.

These problems are commonly asked in technical interviews and cover a wide range of topics, including data structures, algorithms, and problem-solving techniques.

Leetcode Stats

Show some ❤️ by starring ⭐ this repository if you like it!

Contact for work, email: [email protected]

LeetCode Logo

GitHub stars GitHub forks GitHub watchers

linkedin

Buy Me A Coffee

What is Leetcode? 🧑‍💻

Leetcode is a popular online platform that provides a collection of coding challenges. It is widely used by software engineers and interview candidates to practice coding skills and prepare for technical interviews. Leetcode offers a vast array of problems to solve, classified by difficulty level and topic.

About the Top Interview 150 Collection 🏆

The Top Interview 150 collection on Leetcode is a curated set of 150 interview questions that are frequently asked by top tech companies. These questions are carefully selected to cover essential concepts and algorithms that interviewers expect candidates to be familiar with.

Tips for Solving Problems 💡

Here are some helpful strategies to tackle different types of problems in this repository:

1. Heap for Top K Elements 🔼

If you need to find the top K largest, smallest, or closest elements among N elements, use a Heap. This is efficient for problems that require constant updates to the top K elements.

2. Binary Search or Two Pointers for Sorted Input 🔍➡️⬅️

When working with sorted arrays, lists, or matrices, consider using Binary Search or the Two Pointers technique to optimize the solution.

3. Backtracking or BFS for Combinations and Permutations 🔄🔍

For problems requiring exploration of all combinations or permutations, use Backtracking or Breadth-First Search (BFS).

4. BFS or DFS for Trees and Graphs 🌳🔗

Most tree or graph-related problems can be solved effectively using either Breadth-First Search (BFS) or Depth-First Search (DFS).

5. Stack for Converting Recursion to Iteration 📚

Any problem solved by recursion can be converted to an iterative solution using a stack to simulate the call stack.

6. Optimizing Array Problems 📊

For array-related problems with O(n^2) solutions, you can often optimize to O(n) with a HashMap or Set, or to O(n log n) with sorting.

7. Dynamic Programming for Optimization Problems 🚀

Dynamic Programming is key for problems that involve maximizing or minimizing some value, leveraging previous subproblem results to build up the solution.

8. Trie for String Manipulation 🔤

For problems involving multiple strings or searching for common substrings, consider using a Trie or HashMap. If we need to search or manipulate multiple strings, Trie will be the most suitable data structure.

9. Fast & Slow Pointers for Linked Lists 🔄🏃‍♂️🏃‍♀️

In LinkedList problems where additional memory usage is restricted, use the Fast & Slow Pointers method to efficiently solve problems like detecting cycles or finding the middle element.

Repository Structure 🗂️

This repository is organized by problem number, with each problem having its own directory. Inside each problem directory, you will find the solution file(s) along with a README file that provides a problem description, constraints, and additional notes if necessary.

How to Use This Repository 🚀

Navigate through the problem directories to explore solutions. Each directory contains the solution files, including explanations and sample input/output. You can practice implementing your solutions and compare them with those provided.

Feel free to contribute by submitting your solutions or improvements. Open a pull request to share your contributions.

Resources 📚

Happy coding and good luck with your interview preparation! 🎉