
Remove duplicates from a sorted array in place by tracking the last unique index and a forward pointer, overwriting duplicates and returning the length with O(n) time and O(1) space.
Buy on days when the next day's price rises and sell the next day to maximize profit with multiple transactions, iterating through prices once for O(n) time and O(1) space.
Rotate the array to the right by k steps in place using a three-step reverse: reverse entire array, then first k, then last n-k, achieving O(n) time and O(1) space.
Learn how to solve LeetCode 217: contains duplicate in Java by using a hash set to detect repeats during a single pass, achieving O(n) time and O(n) space.
Master binary representation by learning base two, digits, and place values from ones to powers of two, and convert between binary and decimal.
Learn how to use xor to find the unique element in an array where all others appear twice, achieving linear time and constant space.
Resolve intersection of two arrays by building a frequency hash table from nums1 and scanning nums2 to collect common elements, decrementing frequencies to respect counts.
Increment a large integer from a digits array by one, handling trailing nines and all-nines with a new array of length plus one.
Move zeros to the end in place with a two-pointer approach that preserves non-zero order, swapping as needed for an O(n) time, O(1) space solution.
Solve the two sum problem by iterating once, using a hash table to store seen numbers and return indices whose sum equals the target.
Demonstrates validating a 9x9 sudoku by ensuring rows, columns, and 3x3 boxes contain digits 1–9 using a hash set, with periods as empties, and O(n^2) time.
rotate an n by n matrix 90 degrees clockwise in place by transposing the matrix and reversing each row, using constant space and O(n^2) time.
Sort the array and apply a two-pointer approach to find unique triplets that sum to zero, advancing pointers to skip duplicates.
Demonstrate solving LeetCode 73 set matrix zeros in Java, moving from a copy-based approach to two-array tracking and an in-place O(1) solution using the first row and column as indicators.
Group anagrams from a string array by sorting each word's letters and using a hash map to collect words by their sorted form. Return the lists of anagram groups.
Master reversing a character array in place by swapping symmetric elements with constant memory using a two-pointer loop. Note that reversing a string in Java requires creating a new string.
Reverse a signed 32-bit integer by extracting digits with mod ten and building the result. Check for overflow by validating the reverse operation and return zero if out of range.
Tackle LeetCode 387's first unique character by returning its index or -1. Use a hash table to count frequencies, then scan for the first frequency-one character.
Determine if strings s and t are an anagram using a 26-element frequency array, balancing counts by incrementing for s and decrementing for t, in O(n) time and O(1) space.
Learn to determine a string's palindrome status by filtering to alphanumeric characters, converting to lowercase, and comparing mirrored indices to confirm a match.
Implement string to integer (atoi) in Java by trimming spaces, handling an optional sign, and parsing digits until a non-digit. Note time complexity is O(n) and space complexity is O(n).
Find the index of the first occurrence of a needle in a haystack using a nested loop, returning the index or -1, with O(n*m) time and O(1) space.
Find the longest common prefix in an array of strings by shrinking the prefix with each word, returning an empty string when none, and noting O(n*m) time.
Learn to solve the longest substring without repeating characters using a sliding window and a hash set, with left and right pointers achieving linear time and space.
Learn to delete a middle node in a linked list using only access to that node by copying the next node's value and bypassing it, achieving O(1) time and space.
Explain how to remove the nth node from the end of a linked list in one pass using a dummy head and slow–fast pointers, maintaining a gap of n.
Learn to reverse a linked list in Java by iterating with current, previous, and next pointers, flipping links, and returning the new head in O(n) time and O(1) space.
Merge two sorted linked lists by using two pointers, attaching the smaller node each step, and append the rest, yielding O(n+m) time and O(1) space.
Explore solving palindrome linked lists in Java by using fast and slow pointers to locate the middle, reverse the second half, and compare halves in O(n) time and O(1) space.
Detect a linked list cycle with the two-pointer technique; slow and fast pointers meet to signal a cycle, otherwise fast reaches null, in O(n) time and O(1) space.
Learn recursive depth-first search on binary trees, exploring preorder, inorder, and postorder traversals with stack-based visualization, and understand how recursion visits left and right nodes.
Master breadth first search by traversing a binary tree level by level with a queue, starting at the root and visiting left-to-right, with a Java linked list implementation.
Compute the maximum depth of a binary tree using a recursive approach. Return zero for null nodes; otherwise, one plus the max of left and right depths, with Java Math.max.
Learn to validate a binary search tree using in-order traversal and a stack, confirming left nodes are smaller and right nodes larger, with complexity discussed.
Implement a recursive Java solution to check binary tree symmetry using a helper that compares mirrored node pairs—left-left with right-right and left-right with right-left—while handling nulls.
Learn to perform binary tree level order traversal in Java using breadth-first search with a queue to produce a 2d list of node values level by level.
Convert a sorted array into a height balanced binary search tree using the middle element as root and recursively build left and right subtrees with binary search bounds.
Learn zigzag level order traversal of a binary tree using bfs with a left-to-right flag, processing each level and alternating direction to build a list of levels.
construct a binary tree from preorder and inorder traversals using recursion and a hashmap of inorder indices to build root, left, and right subtrees.
Merge two sorted arrays in place by using three pointers from the end to fill nums1, achieving O(m+n) time with O(1) space.
Leverage binary search with the isBadVersion API to locate the first bad version efficiently, minimize API calls to log n, and use a safe midpoint to prevent overflow.
Learn how dynamic programming tackles problems by breaking them into smaller subproblems, storing results in a hash table to avoid duplicate work, and speeding up Fibonacci calculations.
Explore dynamic programming for LeetCode 70: count ways to climb n steps with 1 or 2 steps, using a recursive definition, base cases, and memoization for O(n) time and space.
Maximize profit from a transaction using a prices array by buying at lowest price and selling later, with O(n) time and O(1) space, or zero if no profit is possible.
Learn Kadane's algorithm to compute the maximum subarray sum by maintaining a current sum and a running maximum, achieving O(n) time and O(1) space.
Explore the house robber problem with dynamic programming by computing the maximum loot up to each house, using prior and two-steps-ago results, and optimize to O(1) space.
Master the jump game: use a single pass to track the farthest reachable index in the nums array and return true if you can reach the last index, otherwise false.
Implement an array handler with reset and shuffle methods for the LeetCode design problem. Use a clone and the random library to perform an O(n) shuffle that preserves original state.
Implement a min stack in java with push, pop, top, and getMin in constant time using a node-based linked list that tracks the minimum at each node.
Implement fizzbuzz for leetcode 412 in java by looping from 1 to n and appending fizz, buzz, or fizzbuzz to a string list. Note the O(n) time and space complexity.
Count primes by marking composites in a boolean array below n. Start at two and mark multiples, using the square root of n to limit work.
Identify power-of-three status by dividing by three in a while loop until one, or verify with a base-change logarithm and modulo to check for an integer result.
Convert roman numerals to integers using subtractive notation with a right-to-left scan. Implement in Java with a running total, current and previous values, achieving O(n) time and O(1) space.
master bit manipulation to count the number of one bits in a 32-bit unsigned integer using bitwise and and left shifts, with a simple counter loop.
Compute the hamming distance between two integers using xor and a shifting bit approach in Java, counting differing bits with a 32-iteration, constant-space loop.
Reverse the bits of a 32-bit unsigned integer using bit manipulation, checking the least significant bit and shifting to build the result. It runs in constant time and space.
Build the first numrows rows of Pascal's triangle as a list of lists, with ones on the edges and inner values as sums of the two above.
Use a stack to validate strings containing (), {}, and []; push on opening, pop on closing to ensure proper type and order, achieving linear time and space.
solve the missing number problem in 0 to n by summing nums and the full range, or by xor based bit manipulation, achieving O(n) time and O(1) space.
Explore graphs from a beginner perspective, learn how to represent a graph in Java as a data structure and how to traverse it. Then tackle practice questions with practical approaches.
Explore graph representations, including directed and undirected graphs, and learn key structures like adjacency list, adjacency matrix, and incidence matrix, to enable graph traversals for LeetCode problems.
demonstrates depth first search on a directed graph from a, using adjacency lists, recursion, and a visited set to print nodes in traversal order.
Learn breadth first search on graphs using a queue, starting from node A, exploring neighbors in order with an adjacency list, and implement it in Java.
Determine if a path exists between source and destination in an undirected graph by building an adjacency list from edges and performing a breadth-first search with a visited set.
Start at room zero, collect keys, and unlock rooms. Use a depth-first search with a visited set to determine if all rooms are reachable and return true or false.
Model LeetCode 207 course schedule as a graph of courses and prerequisites, use DFS with an adjacency list to detect cycles, and determine if all courses can be finished.
Welcome!
Hello everyone, and welcome to the course that will help you prepare for your coding interviews!
Specifically, we will be breaking down the problems of LeetCode's Top Interview Questions playlist. This playlist includes problems that are very commonly asked by interviewers from large tech companies such as Apple, Meta, Google, Uber, and many more! We will learn how to approach problems of all kinds, such as those consisting of Arrays, Strings, Linked Lists, Trees, Dynamic Programming, Design, Math, and general knowledge, while also learning useful concepts and tricks which will help when facing more difficult problems.
What is LeetCode?
Simply put, LeetCode is a large repository filled with interview questions asked by the top tech companies around the world (Google, Facebook, Amazon, and many more).
The main problem as a new user on LeetCode is that there are ENDLESS amounts of questions that you can find on there so you may not know which questions are the most common/beneficial to go over. This course's purpose is to provide a solution to this issue, as I go over the Top Inteview Questions recommended by LeetCode. If you are looking to ace your upcoming coding interview or even just to strengthen your problem solving skills, then look no further as you have found the one-stop-shop to become a problem solving machine.
Course Overview
For each problem in the playlist, I have a video dedicated to explaining the thought process in detail which will lead us to the most efficient solution, paired with a visual to aid in explaining the algorithm. After we understand the approach for the most efficient solution, I will translate the visual into Java code, breaking down every line as I code it. After the entire solution is implemented, we will analyze the time and space complexity of the solution.