Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Master LeetCode: Conquer the Top 150 Problems
Rating: 4.5 out of 5(1 rating)
232 students

Master LeetCode: Conquer the Top 150 Problems

Master data structures & algorithms with step-by-step solutions to ace technical interviews & land your dream job.
Created byHarshit Shah
Last updated 11/2025
English

What you'll learn

  • Master data structures and algorithms essential for solving LeetCode’s top 150 problems
  • Develop advanced problem-solving skills to tackle complex coding challenges efficiently
  • Learn to recognize patterns across different problem types and apply optimal solutions
  • Improve coding speed and efficiency to solve multiple problems within time constraints, preparing for technical interviews
  • Analyze time and space complexity to optimize solutions and impress interviewers with efficient code
  • Master dynamic programming techniques to solve the most challenging algorithmic problems
  • Learn effective whiteboarding techniques to clearly communicate you systematic debugging skills to identify and fix errors quickly during interviews.
  • Build a strategic approach to interview preparation, including spaced repetition and targeted practice.
  • Implement clean, readable code that follows best practices valued by top tech companies.
  • Gain confidence in explaining complex algorithms through practice with clear verbal explanations.
  • Apply problem decomposition strategies to break down intimidating problems into manageable components.

Course content

20 sections96 lectures10h 51m total length
  • Merge Sorted Array8:15

    Mastering Merge Sorted Arrays: LeetCode #88 Solution


    Problem Overview

    In this lesson, we tackle LeetCode Problem 88: "Merge Sorted Array," where you need to combine two sorted integer arrays into a single sorted array in-place. The first array has enough space at the end to accommodate the second array.


    Complexity Analysis

    • Time Complexity: O(m+n) where m and n are the lengths of the arrays

    • Space Complexity: O(1) as we modify the first array in-place


    Key Concepts Covered

    • Two-pointer technique

    • In-place array manipulation

    • Merge operation from merge sort

    • Handling sorted data efficiently


    Learning Points

    • How to efficiently merge two sorted arrays without extra space

    • Working backwards to avoid overwriting elements

    • Edge case handling when one array is empty

    • Practical application of the two-pointer technique in sorting problems


    Join me as we solve this fundamental array manipulation problem step-by-step, building a solid foundation for more complex algorithm challenges! This solution technique appears frequently in technical interviews and is essential for your algorithmic toolkit.

  • Remove Element6:19

    Remove Element - LeetCode 27


    Problem Overview

    In this lesson, we'll tackle LeetCode's Problem 27: Remove Element. This is a fundamental array manipulation problem that tests your ability to modify an array in-place while maintaining certain conditions.


    Key Concepts Covered

    • In-place array modification

    • Two-pointer technique

    • Element removal without auxiliary storage

    • Array traversal and manipulation


    Solution Approach

    We'll implement the efficient two-pointer technique to solve this problem, where one pointer tracks the position for the next valid element, while another scans through the array.


    Time & Space Complexity

    • Time Complexity: O(n) - we traverse the array only once

    • Space Complexity: O(1) - we modify the array in-place without using extra space


    Learning Points

    • Understanding how to modify arrays in-place

    • Implementing the two-pointer technique effectively

    • Handling edge cases with arrays

    • Optimizing solutions by avoiding unnecessary operations


    Join me in this lesson to master this fundamental array manipulation technique that appears frequently in coding interviews!

  • Remove Duplicates from Sorted Array7:26

    Remove Duplicates from Sorted Array: A Step-by-Step Guide


    Problem Overview

    In LeetCode's Problem 26, you are given a sorted array of integers, and your task is to remove duplicates "in-place" so that each element appears only once while maintaining the relative order of the elements.


    Complexity Analysis

    • Time Complexity: O(n) - We make a single pass through the array

    • Space Complexity: O(1) - We modify the array in-place with only a few pointer variables


    Key Concepts Covered

    • Two-pointer technique

    • In-place array manipulation

    • Handling sorted arrays efficiently


    Learning Points

    • How to solve problems without using extra space

    • Importance of taking advantage of the array's sorted property

    • Understanding "in-place" operations in arrays

    • Implementing the two-pointer approach for array manipulation


    What You'll Learn

    In this lesson, we'll walk through a clean, efficient solution that uses the two-pointer technique to solve this common interview problem. You'll master a fundamental array manipulation pattern that appears frequently in coding interviews at top tech companies.

  • Remove Duplicates from Sorted Array II7:08

    Solving LeetCode 80: Remove Duplicates from Sorted Array II


    Brief problem overview

    This problem asks you to modify a sorted array in-place so that each unique element appears at most twice, and return the length of the modified array.


    Time and space complexity: The optimal solution has O(n) time complexity, where n is the length of the input array, and O(1) space complexity as we modify the array in-place.


    Key concepts covered:

    • Two-pointer technique

    • In-place array manipulation

    • Array traversal

    • Counting duplicates


    Learning points: You'll learn how to efficiently handle duplicates in a sorted array using the two-pointer technique. This problem helps practice in-place array modifications and understand how to maintain specific constraints (in this case, allowing at most two occurrences of each element) while processing an array.


    Check the introduction section to download the source code for the solution.

  • Majority Element6:12

    Brief problem overview: LeetCode problem 169 (Majority Element) asks you to find the element that appears more than n/2 times in an array of n elements. Your task is to return this majority element which is guaranteed to exist in the array.


    Time and space complexity: The optimal solution achieves O(n) time complexity and O(1) space complexity using the Boyer-Moore Voting Algorithm.


    Key concepts covered:

    • Boyer-Moore Voting Algorithm

    • Array traversal

    • Counting techniques

    • Divide and conquer (alternative approach)

    • Hash maps (alternative approach)


    Learning points: By solving this problem, you'll learn how to identify elements with specific frequency characteristics in an array. You'll practice implementing the elegant Boyer-Moore Voting Algorithm which efficiently finds a majority element without using extra space. This problem also demonstrates how a clever algorithm can outperform more obvious solutions like sorting or using a hash map.


    Check the introduction section to download the source code for the solution.

  • Rotate Array5:44

    Brief problem overview: In this lecture, we'll solve LeetCode's Rotate Array problem, which asks you to rotate an array to the right by k steps, where each element moves k positions.


    Time and space complexity: The optimal solution has O(n) time complexity and O(1) space complexity.


    Key concepts covered: Array manipulation, in-place algorithms, reverse array technique, modular arithmetic.


    Learning points: You'll learn how to efficiently rotate arrays without using extra space, practice implementing the reverse array technique, understand how to handle edge cases like when k is larger than the array length, and see how clever mathematical insights can lead to elegant solutions for array manipulation problems.


    Check the introduction section to download the source code for the solution.

  • Best Time to Buy and Sell Stock7:59

    Brief problem overview: In LeetCode problem 121 Best Time to Buy and Sell Stock, you need to maximize profit by determining the best single day to buy a stock and the best later day to sell it, given an array of stock prices.


    Time and space complexity: The optimal solution has O(n) time complexity and O(1) space complexity, where n is the number of days/prices in the array.


    Key concepts covered:

    • One-pass algorithm

    • Dynamic programming simplified

    • Greedy approach

    • Array traversal

    • Min/max tracking


    Learning points:

    • How to implement a single-pass solution to optimize profit calculation

    • Techniques for tracking minimum values while iterating through arrays

    • Understanding when to use greedy algorithms for optimization problems

    • Efficiently solving problems without using extra space

    • Recognizing and avoiding unnecessary computations in array processing


    Check the introduction section to download the source code for the solution.

  • Best Time to Buy and Sell Stock II4:07

    Brief problem overview: This problem asks you to maximize profit by buying and selling stocks multiple times over a given period. You are given an array where each element represents the stock price on a particular day, and you need to determine the maximum profit you can make.


    Time and space complexity: The optimal solution has O(n) time complexity, where n is the number of days. The space complexity is O(1) as we only need a few variables to track the profit.


    Key concepts covered:

    • Greedy algorithms

    • Array traversal

    • Profit maximization

    • Multiple transaction optimization


    Learning points: By solving this problem, you'll learn how to implement a greedy approach to optimize profits in a stock trading scenario. You'll practice identifying profitable transactions by comparing adjacent days and understand how to accumulate profits incrementally rather than trying to find optimal buy-sell pairs.


    Check the introduction section to download the source code for the solution.

  • Jump Game7:11

    Brief problem overview: In LeetCode problem 55, Jump Game, you are given an array of non-negative integers representing the maximum jump length at each position. You need to determine if you can reach the last index starting from the first position.


    Time and space complexity: The optimal solution has O(n) time complexity where n is the length of the array, and O(1) space complexity as we only need to track the furthest reachable position.


    Key concepts covered:

    • Greedy algorithms,

    • Array traversal,

    • Optimization


    Learning points: In this lecture, you'll learn how to approach problems that can be solved using greedy strategies. You'll practice identifying when to use a greedy approach instead of more complex solutions like dynamic programming. You'll also learn how to track and update reachable positions efficiently while traversing through an array.


    Check the introduction section to download the source code for the solution.

  • Jump Game II8:14

    Brief problem overview:

    In this problem, you're given an array of integers representing the maximum number of steps you can jump forward from each position. The goal is to find the minimum number of jumps needed to reach the last index of the array.


    Time and space complexity:

    The optimal solution has O(n) time complexity and O(1) space complexity, where n is the length of the input array.


    Key concepts covered:

    • Greedy algorithms

    • Array traversal

    • Dynamic programming concepts

    • Jump optimization


    Learning points:

    In this lecture, you'll learn how to approach this classic jumping problem using a greedy approach. You'll understand how to track the current reach and maximum reach to minimize jumps, avoiding the common pitfalls of recursive solutions that lead to time limit exceeded errors. This problem helps strengthen your ability to identify when greedy solutions are applicable and how to implement them efficiently.


    Check the introduction section to download the source code for the solution.

  • H-Index9:02

    Brief problem overview: In this lecture, we'll solve LeetCode Problem 274 (H-Index), which asks us to calculate the h-index of a researcher based on their citation counts. The h-index measures both the productivity and impact of a researcher's publications.


    Time and space complexity: The optimal solution has a time complexity of O(n log n) if we use sorting, or O(n) if we use counting sort. The space complexity is O(1) for the sorting approach or O(n) for the counting sort approach.


    Key concepts covered:

    • Sorting

    • Counting Sort

    • Array Manipulation

    • Binary Search (alternative approach)

    • Understanding the H-Index concept


    Learning points: You'll learn how to analyze a problem with a non-intuitive definition, transform it into an algorithmic solution, and optimize it. This problem helps practice array manipulation and understand when to use different sorting techniques based on the constraints of the input data.


    Check the introduction section to download the source code for the solution.

  • Insert Delete GetRandom O(1)5:05

    Brief problem overview: In this lecture, we will implement a data structure RandomizedSet which supports inserting elements, removing elements, and getting a random element from the set, all in O(1) time complexity.


    Time and space complexity: The optimal solution has O(1) time complexity for all operations (insert, remove, getRandom) and O(n) space complexity where n is the number of elements in the set.


    Key concepts covered:

    • Hash Maps

    • Arrays

    • Constant-time operations

    • Random access


    Learning points: You'll learn how to combine a hash map and an array to achieve O(1) operations for all required functionalities. This problem demonstrates a clever technique of swapping elements to maintain constant time deletion without disrupting the ability to get random elements efficiently. You'll also understand the trade-offs between different data structures and how to leverage their strengths in combination.


    Check the introduction section to download the source code for the solution.

  • Product of Array Except Self8:25

    Brief problem overview:

    In this problem, you need to calculate a new array where each element is the product of all numbers in the original array except the number at that index. The challenge is to do this without using division and in O(n) time.


    Time and space complexity:

    The optimal solution achieves O(n) time complexity and O(1) space complexity (excluding the output array).


    Key concepts covered:

    • Prefix and suffix products

    • Array manipulation

    • In-place calculation techniques

    • Optimizing space complexity


    Learning points:

    In this lecture, you'll learn how to solve a seemingly complex problem with an elegant solution that avoids division. You'll practice using prefix/suffix product calculations, understand how to optimize both time and space complexity, and see how to approach problems that initially seem to require nested loops but can be solved linearly.


    Check the introduction section to download the source code for the solution.

  • Gas Station8:39

    Brief problem overview:

    In this problem, you need to find the starting gas station index that allows you to complete a circular route. You have arrays representing gas available at each station and the cost to travel to the next station, and must determine if a valid starting point exists.


    Time and space complexity:

    The optimal solution has O(n) time complexity as we traverse the array once, and O(1) space complexity as we use only a few variables regardless of input size.


    Key concepts covered:

    • Greedy algorithms

    • Circular array traversal

    • Running sum calculations

    • Problem constraints analysis


    Learning points:

    In this lecture, you'll learn how to approach problems requiring circular traversal with limited resources. You'll practice implementing a greedy approach to find an efficient solution without brute force, and understand how to use mathematical properties of the problem to eliminate unnecessary calculations.


    Check the introduction section to download the source code for the solution.

  • Roman to Integer4:41

    Roman to Integer: Convert Roman Numerals to Numbers


    Brief problem overview:

    In this lecture, we tackle LeetCode problem 13 which asks us to convert a Roman numeral string into an integer value. This requires understanding the rules of Roman numerals and handling special cases where smaller values precede larger ones.


    Time and space complexity:

    • Time complexity: O(n) where n is the length of the input string

    • Space complexity: O(1) as we use a fixed-size hash map regardless of input size


    Key concepts covered:

    • Hash maps / Dictionaries

    • String traversal

    • Roman numeral system rules

    • Special case handling


    Learning points:

    • How to use a hash map to store symbol-value pairs

    • Implementing logic for Roman numeral subtraction rules (IV = 4, IX = 9, etc.)

    • Efficiently traversing a string while making decisions based on current and next characters

    • Converting a complex representation system into integers

    • Writing clean, readable code for a common interview problem


    Check the introduction section to download the source code for the solution.

  • Length of Last Word2:57

    Length of Last Word - LeetCode Problem 58


    Brief problem overview: This lecture covers how to find the length of the last word in a string. A word is a maximal substring consisting of non-space characters.


    Time and space complexity:

    The optimal solution has O(n) time complexity, where n is the length of the input string, and O(1) space complexity as we only use a few variables.


    Key concepts covered:

    • String manipulation

    • String traversal

    • Handling edge cases with whitespace

    • Basic string parsing


    Learning points:

    By solving this problem, you'll practice working with strings, learn how to efficiently handle trailing spaces, and understand a simple but practical string parsing technique. This problem helps build fundamental string manipulation skills that are useful in many real-world applications.


    Check the introduction section to download the source code for the solution.

  • Longest Common Prefix7:17

    Brief problem overview: In this lecture, we'll solve the Longest Common Prefix problem, which asks us to find the longest common prefix string amongst an array of strings.


    Time and space complexity: The optimal solution runs in O(S) time where S is the sum of all characters in all strings. The space complexity is O(1) as we only need a constant amount of extra space.


    Key concepts covered:

    String manipulation, character comparison, horizontal scanning approach, divide and conquer optional approach


    Learning points:

    You'll learn how to efficiently compare multiple strings character by character, handle edge cases like empty arrays or strings, and implement a clean solution for prefix matching. This problem helps practice string iteration techniques and builds foundational skills for more complex string algorithms.


    Check the introduction section to download the source code for the solution.

  • Reverse Words in a String3:23

    Brief problem overview:

    This problem requires you to reverse the order of words in a given string while preserving the words themselves. Extra spaces between words should be reduced to a single space, and leading/trailing spaces should be removed.


    Time and space complexity:

    The optimal solution has O(n) time complexity where n is the length of the input string, and O(n) space complexity to store the reversed words.


    Key concepts covered:

    • String manipulation

    • Two-pointer technique

    • In-place operations (for certain approaches)

    • Split and join operations


    Learning points:

    In this lecture, you'll learn how to efficiently process strings by splitting them into words, removing extra spaces, and reconstructing them in reverse order. You'll practice string traversal techniques and understand how to optimize memory usage when handling string operations. This problem highlights the importance of carefully managing string transformations while preserving specific formatting requirements.


    Check the introduction section to download the source code for the solution.

  • Zigzag Conversion10:33

    Brief problem overview: In this lecture, we tackle LeetCode Problem 6, Zigzag Conversion, which asks us to convert a string into a zigzag pattern across multiple rows and then read it line by line to create a new string output.


    Time and space complexity: The optimal solution has a time complexity of O(n) where n is the length of the input string, and a space complexity of O(n) to store the converted string.


    Key concepts covered:

    • String manipulation

    • pattern recognition

    • array manipulation

    • mathematical relationships

    • simulation.


    Learning points: By solving this problem, you'll strengthen your understanding of string processing techniques, improve your ability to identify and implement mathematical patterns, and learn how to efficiently simulate a visual process in code. You'll also practice optimizing your solution by identifying the direct mapping between input and output positions.


    Check the introduction section to download the source code for the solution.

  • Find the Index of the First Occurrence in a String5:50

    LeetCode Problem 28: Find the Index of the First Occurrence in a String ?


    Problem Overview ?

    This problem asks you to find the first occurrence of a needle string within a haystack string, returning the index of the first character if found, or -1 if not present.


    Complexity Analysis ⏱️

    • Time Complexity: O(n×m) where n is the length of the haystack and m is the length of the needle

    • Space Complexity: O(1) as we only use a constant amount of extra space


    Key Concepts ?

    • String manipulation

    • Substring search algorithms

    • Two-pointer technique

    • Pattern matching


    Learning Points ?

    • How to efficiently compare strings and substrings

    • Implementing simple string search algorithms

    • Edge case handling (empty strings, needle longer than haystack)

    • Understanding when to use built-in functions vs custom implementations


    What You'll Learn ?

    In this lecture, you'll learn how to implement a solution to the string matching problem using both the brute force approach and optimize it with proper string comparison techniques. This pattern appears frequently in technical interviews and real-world applications!

Requirements

  • Basic programming knowledge in any language (e.g., Python, Java, C++)
  • Familiarity with fundamental data structures (arrays, strings, linked lists)
  • Understanding of basic algorithms and time complexity (Big O notation)
  • Comfort with problem-solving and logical thinking
  • Basic understanding of object-oriented programming concepts
  • Familiarity with at least one integrated development environment (IDE) or code editor
  • Access to a computer with internet connection to practice on LeetCode’s platform
  • Willingness to dedicate time for consistent practice and problem-solving
  • Basic math skills, including algebra and discrete mathematics
  • Familiarity with version control systems like Git (helpful but not required)
  • Understanding of basic database concepts and SQL (for certain types of problems)
  • Patience and perseverance when facing challenging problems
  • Ability to read and understand technical documentation and problem statements
  • Basic knowledge of computer architecture and memory management (helpful for optimizing solutions)

Description

Master LeetCode: Conquer the Top 150 Problems

Struggling with coding interviews? This comprehensive course will transform you from a coding novice to a LeetCode master by methodically tackling all 150 of LeetCode’s most important problems.

What You’ll Learn

In this course, you’ll develop a systematic approach to solving any coding challenge. Rather than memorizing solutions, you’ll learn a step-by-step formula that works for every problem:

• Simplify complex problems into manageable components

• Recognize common patterns across different problem types

• Create effective implementation plans before coding

• Write clean, efficient code that interviewers love

• Debug systematically when things don’t work as expected

Course Structure

Each section follows a consistent format designed for maximum learning retention:

• Problem Breakdown: Clear explanation of what the problem is asking

• Pattern Recognition: Identifying which data structures and algorithms apply

• Solution Development: Building the approach step-by-step

• Implementation: Writing clean, optimized code

• Time & Space Analysis: Understanding the efficiency of our solution

• Common Pitfalls: Avoiding mistakes that trip up most candidates

Who This Course Is For

This course is perfect for:

• Software engineers preparing for technical interviews

• Computer science students looking to strengthen their problem-solving skills

• Self-taught programmers wanting to fill knowledge gaps

• Anyone who has struggled with LeetCode’s challenging problems

Prerequisites

To get the most from this course, you should have:

• Basic programming knowledge in any language

• Familiarity with fundamental data structures (arrays, strings, linked lists)

• Understanding of Big O notation (helpful but not required)

Your Instructor

As an experienced software engineer who has conducted hundreds of technical interviews, I’ve distilled the exact methods used by top performers. I focus on teaching you not just how to solve these specific 150 problems, but how to approach any coding challenge with confidence.

Don’t waste time randomly solving problems without a strategy. Join this course to develop a structured approach that will serve you throughout your entire programming career.

Who this course is for:

  • Software engineers preparing for technical interviews
  • CS students strengthening algorithm skills
  • Self-taught programmers filling knowledge gaps
  • Bootcamp graduates deepening technical expertise
  • Job seekers targeting tech companies
  • Developers wanting to master data structures and algorithms
  • Professionals advancing careers through better technical skills
  • Anyone struggling with LeetCode problems who has basic programming knowledge