ByteBunny
ByteBunny
leetcode

blind 75 leetcode questions

blog.title
0 views
13 min read
#leetcode

LeetCode Blind 75: Comprehensive Guide and Solutions

Introduction

The LeetCode Blind 75 list is a curated set of 75 problems that are essential for coding interview preparation. This guide categorizes each problem by topic, providing descriptions, difficulty levels, and links to both the LeetCode problem pages and detailed solutions.

Arrays

Resources to Learn About Arrays

Time and Space Complexities

  • Access: O(1) time
  • Search: O(n) time
  • Insertion: O(n) time (if shifting elements is required)
  • Deletion: O(n) time (if shifting elements is required)
  • Space Complexity: O(n)

Problems

ProblemDescriptionDifficultySolution
Two SumFind two numbers in an array that add up to a given target. You cannot use the same element twice.EasyDetailed Solution
Best Time to Buy and Sell StockFind the maximum profit you can achieve from buying and selling stock.EasyDetailed Solution
Contains DuplicateDetermine if an array contains any duplicates.EasyDetailed Solution
Product of Array Except SelfGiven an array, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].MediumDetailed Solution)
Maximum SubarrayFind the contiguous subarray which has the largest sum.EasyDetailed Solution
Maximum Product SubarrayFind the contiguous subarray within an array which has the largest product.MediumDetailed Solution
Find Minimum in Rotated Sorted ArrayFind the minimum element in a rotated sorted array.MediumDetailed Solution
Search in Rotated Sorted ArrayGiven a rotated sorted array, find the index of a target value.MediumDetailed Solution
3 SumFind all unique triplets in the array which gives the sum of zero.MediumDetailed Solution
Container With Most WaterGiven n non-negative integers representing an elevation map, find two lines that together with the x-axis form a container, such that the container contains the most water.MediumDetailed Solution

Binary

ProblemDescriptionDifficultySolution
Sum of Two IntegersCalculate the sum of two integers a and b, but you are not allowed to use the operator + and -.MediumDetailed Solution
Number of 1 BitsWrite a function that takes an unsigned integer and returns the number of '1' bits it has.EasyDetailed Solution
Counting BitsGiven an integer num, return an array of the number of 1's in the binary representation of each number in the range [0, num].EasyDetailed Solution
Missing NumberGiven an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.EasyDetailed Solution
Reverse BitsReverse bits of a given 32 bits unsigned integer.EasyDetailed Solution

Dynamic Programming

ProblemDescriptionDifficultySolution
Climbing StairsGiven n steps, find the number of distinct ways you can climb to the top.EasyDetailed Solution
Coin ChangeGiven different coin denominations and a total amount, find the minimum number of coins needed to make up that amount.MediumDetailed Solution
Longest Increasing SubsequenceGiven an integer array, return the length of the longest increasing subsequence.MediumDetailed Solution
Longest Common SubsequenceGiven two strings, find the length of their longest common subsequence.MediumDetailed Solution
Word Break ProblemGiven a string and a dictionary of words, determine if the string can be segmented into a space-separated sequence of one or more dictionary words.MediumDetailed Solution
Combination SumGiven an array of distinct integers and a target number, return all possible combinations that add up to the target.MediumDetailed Solution
House RobberGiven a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.MediumDetailed Solution
House Robber IIAll houses are arranged in a circle. Find the maximum amount of money you can rob tonight without alerting the police.MediumDetailed Solution
Decode WaysGiven an encoded message, determine the total number of ways to decode it.MediumDetailed Solution
Unique PathsA robot is located at the top-left corner of a m x n grid. Find how many possible unique paths there are to reach the bottom-right corner.MediumDetailed Solution
Jump GameGiven an array of non-negative integers, determine if you are able to reach the last index.MediumDetailed Solution

Graph

ProblemDescriptionDifficultySolution
Clone GraphGiven a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph.MediumDetailed Solution
Course ScheduleDetermine if you can finish all courses given the prerequisites.MediumDetailed Solution
Pacific Atlantic Water FlowFind all the cells that can flow to both the Pacific and Atlantic oceans.MediumDetailed Solution
Number of IslandsGiven a 2D grid map of '1's (land) and '0's (water), count the number of islands.MediumDetailed Solution
Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.MediumDetailed Solution
Alien Dictionary (Leetcode Premium)Given a sorted dictionary of an alien language, find the order of characters in the language.HardDetailed Solution
Graph Valid Tree (Leetcode Premium)Given n nodes labeled from 0 to n-1 and a list of undirected edges, determine if these edges make up a valid tree.MediumDetailed Solution
Number of Connected Components in an Undirected Graph (Leetcode Premium)Given n nodes and a list of edges, find the number of connected components in an undirected graph.MediumDetailed Solution

Interval

ProblemDescriptionDifficultySolution
Insert IntervalGiven a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).MediumDetailed Solution
Merge IntervalsGiven a collection of intervals, merge all overlapping intervals.MediumDetailed Solution
Non-overlapping IntervalsFind the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.MediumDetailed Solution
Meeting Rooms (Leetcode Premium)Given an array of meeting time intervals, determine if a person could attend all meetings.EasyDetailed Solution
Meeting Rooms II (Leetcode Premium)Given an array of meeting time intervals, find the minimum number of conference rooms required.MediumDetailed Solution

Linked List

ProblemDescriptionDifficultySolution
Reverse a Linked ListReverse a singly linked list.EasyDetailed Solution
Detect Cycle in a Linked ListDetermine if a linked list has a cycle in it.EasyDetailed Solution
Merge Two Sorted ListsMerge two sorted linked lists and return it as a new sorted list.EasyDetailed Solution
Merge K Sorted ListsMerge k sorted linked lists and return it as one sorted list.HardDetailed Solution
Remove Nth Node From End Of ListRemove the nth node from the end of the list and return its head.MediumDetailed Solution
Reorder ListGiven a singly linked list, reorder it to: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → ...MediumDetailed Solution

Matrix

ProblemDescriptionDifficultySolution
Set Matrix ZeroesGiven an m x n matrix, if an element is 0, set its entire row and column to 0.MediumDetailed Solution
Spiral MatrixGiven an m x n matrix, return all elements of the matrix in spiral order.MediumDetailed Solution
Rotate ImageRotate an n x n 2D matrix 90 degrees clockwise.MediumDetailed Solution
Word SearchGiven a 2D board and a word, find if the word exists in the grid.MediumDetailed Solution

String

ProblemDescriptionDifficultySolution
Longest Substring Without Repeating CharactersFind the length of the longest substring without repeating characters in a given string.MediumDetailed Solution
Longest Repeating Character ReplacementGiven a string, find the length of the longest substring containing the same letter you can get after performing k replacements.MediumDetailed Solution
Minimum Window SubstringGiven a string and a string t, find the minimum window in the string which will contain all the characters in t.HardDetailed Solution
Valid AnagramDetermine if two strings are anagrams of each other.EasyDetailed Solution
Group AnagramsGiven an array of strings, group the anagrams together.MediumDetailed Solution
Valid ParenthesesGiven a string containing just the characters '(', ')', ', ', '[' and ']', determine if the input string is valid.EasyDetailed Solution
Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.EasyDetailed Solution
Longest Palindromic SubstringGiven a string, return the longest palindromic substring.MediumDetailed Solution
Palindromic SubstringsGiven a string, count the number of distinct palindromic substrings in it.MediumDetailed Solution
Encode and Decode Strings (Leetcode Premium)Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and decoded back to the original list of strings.MediumDetailed Solution

Tree

ProblemDescriptionDifficultySolution
Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.EasyDetailed Solution
Same TreeGiven two binary trees, write a function to check if they are the same or not.EasyDetailed Solution
Invert/Flip Binary TreeInvert a binary tree.EasyDetailed Solution
Binary Tree Maximum Path SumGiven a non-empty binary tree, find the maximum path sum.HardDetailed Solution
Binary Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes' values.MediumDetailed Solution
Serialize and Deserialize Binary TreeDesign an algorithm to serialize and deserialize a binary tree.HardDetailed Solution
Subtree of Another TreeGiven two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s.EasyDetailed Solution
Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.MediumDetailed Solution
Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree.MediumDetailed Solution
Kth Smallest Element in a BSTGiven a binary search tree, write a function to find the kth smallest element in it.MediumDetailed Solution
Lowest Common Ancestor of BSTGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.MediumDetailed Solution
Implement Trie (Prefix Tree)Implement a trie with insert, search, and startsWith methods.MediumDetailed Solution

Heap

ProblemDescriptionDifficultySolution
Merge K Sorted ListsMerge k sorted linked lists and return it as one sorted list.HardDetailed Solution
Top K Frequent ElementsGiven a non-empty array of integers, return the k most frequent elements.MediumDetailed Solution
Find Median from Data StreamThe median is the middle value in an ordered integer list. Write a function to find the median of the data stream.HardDetailed Solution

Miscellaneous

ProblemDescriptionDifficultySolution
Insert Delete GetRandom O(1)Design a data structure that supports all following operations in average O(1) time.MediumDetailed Solution
LRU CacheDesign a data structure that follows the constraints of a Least Recently Used (LRU) cache.MediumDetailed Solution
Word BreakGiven a string and a dictionary of words, determine if the string can be segmented into a space-separated sequence of one or more dictionary words.MediumDetailed Solution

Advanced

ProblemDescriptionDifficultySolution
Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.HardDetailed Solution
N-QueensThe n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.HardDetailed Solution
LFU CacheDesign and implement a data structure for Least Frequently Used (LFU) cache.HardDetailed Solution

This should give you a good starting point to compile your comprehensive guide for the LeetCode Blind 75 problems. Each entry provides a link to the problem, a brief description, the difficulty level, and a placeholder for your detailed solution. Let me know if you need any more information or assistance!