leetcode
blind 75 leetcode questions

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
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Two Sum | Find two numbers in an array that add up to a given target. You cannot use the same element twice. | Easy | Detailed Solution |
| Best Time to Buy and Sell Stock | Find the maximum profit you can achieve from buying and selling stock. | Easy | Detailed Solution |
| Contains Duplicate | Determine if an array contains any duplicates. | Easy | Detailed Solution |
| Product of Array Except Self | Given an array, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. | Medium | Detailed Solution) |
| Maximum Subarray | Find the contiguous subarray which has the largest sum. | Easy | Detailed Solution |
| Maximum Product Subarray | Find the contiguous subarray within an array which has the largest product. | Medium | Detailed Solution |
| Find Minimum in Rotated Sorted Array | Find the minimum element in a rotated sorted array. | Medium | Detailed Solution |
| Search in Rotated Sorted Array | Given a rotated sorted array, find the index of a target value. | Medium | Detailed Solution |
| 3 Sum | Find all unique triplets in the array which gives the sum of zero. | Medium | Detailed Solution |
| Container With Most Water | Given 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. | Medium | Detailed Solution |
Binary
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Sum of Two Integers | Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. | Medium | Detailed Solution |
| Number of 1 Bits | Write a function that takes an unsigned integer and returns the number of '1' bits it has. | Easy | Detailed Solution |
| Counting Bits | Given an integer num, return an array of the number of 1's in the binary representation of each number in the range [0, num]. | Easy | Detailed Solution |
| Missing Number | Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. | Easy | Detailed Solution |
| Reverse Bits | Reverse bits of a given 32 bits unsigned integer. | Easy | Detailed Solution |
Dynamic Programming
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Climbing Stairs | Given n steps, find the number of distinct ways you can climb to the top. | Easy | Detailed Solution |
| Coin Change | Given different coin denominations and a total amount, find the minimum number of coins needed to make up that amount. | Medium | Detailed Solution |
| Longest Increasing Subsequence | Given an integer array, return the length of the longest increasing subsequence. | Medium | Detailed Solution |
| Longest Common Subsequence | Given two strings, find the length of their longest common subsequence. | Medium | Detailed Solution |
| Word Break Problem | Given 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. | Medium | Detailed Solution |
| Combination Sum | Given an array of distinct integers and a target number, return all possible combinations that add up to the target. | Medium | Detailed Solution |
| House Robber | Given 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. | Medium | Detailed Solution |
| House Robber II | All houses are arranged in a circle. Find the maximum amount of money you can rob tonight without alerting the police. | Medium | Detailed Solution |
| Decode Ways | Given an encoded message, determine the total number of ways to decode it. | Medium | Detailed Solution |
| Unique Paths | A 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. | Medium | Detailed Solution |
| Jump Game | Given an array of non-negative integers, determine if you are able to reach the last index. | Medium | Detailed Solution |
Graph
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Clone Graph | Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. | Medium | Detailed Solution |
| Course Schedule | Determine if you can finish all courses given the prerequisites. | Medium | Detailed Solution |
| Pacific Atlantic Water Flow | Find all the cells that can flow to both the Pacific and Atlantic oceans. | Medium | Detailed Solution |
| Number of Islands | Given a 2D grid map of '1's (land) and '0's (water), count the number of islands. | Medium | Detailed Solution |
| Longest Consecutive Sequence | Given an unsorted array of integers, find the length of the longest consecutive elements sequence. | Medium | Detailed Solution |
| Alien Dictionary (Leetcode Premium) | Given a sorted dictionary of an alien language, find the order of characters in the language. | Hard | Detailed 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. | Medium | Detailed 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. | Medium | Detailed Solution |
Interval
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Insert Interval | Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). | Medium | Detailed Solution |
| Merge Intervals | Given a collection of intervals, merge all overlapping intervals. | Medium | Detailed Solution |
| Non-overlapping Intervals | Find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. | Medium | Detailed Solution |
| Meeting Rooms (Leetcode Premium) | Given an array of meeting time intervals, determine if a person could attend all meetings. | Easy | Detailed Solution |
| Meeting Rooms II (Leetcode Premium) | Given an array of meeting time intervals, find the minimum number of conference rooms required. | Medium | Detailed Solution |
Linked List
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Reverse a Linked List | Reverse a singly linked list. | Easy | Detailed Solution |
| Detect Cycle in a Linked List | Determine if a linked list has a cycle in it. | Easy | Detailed Solution |
| Merge Two Sorted Lists | Merge two sorted linked lists and return it as a new sorted list. | Easy | Detailed Solution |
| Merge K Sorted Lists | Merge k sorted linked lists and return it as one sorted list. | Hard | Detailed Solution |
| Remove Nth Node From End Of List | Remove the nth node from the end of the list and return its head. | Medium | Detailed Solution |
| Reorder List | Given a singly linked list, reorder it to: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → ... | Medium | Detailed Solution |
Matrix
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Set Matrix Zeroes | Given an m x n matrix, if an element is 0, set its entire row and column to 0. | Medium | Detailed Solution |
| Spiral Matrix | Given an m x n matrix, return all elements of the matrix in spiral order. | Medium | Detailed Solution |
| Rotate Image | Rotate an n x n 2D matrix 90 degrees clockwise. | Medium | Detailed Solution |
| Word Search | Given a 2D board and a word, find if the word exists in the grid. | Medium | Detailed Solution |
String
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Longest Substring Without Repeating Characters | Find the length of the longest substring without repeating characters in a given string. | Medium | Detailed Solution |
| Longest Repeating Character Replacement | Given a string, find the length of the longest substring containing the same letter you can get after performing k replacements. | Medium | Detailed Solution |
| Minimum Window Substring | Given a string and a string t, find the minimum window in the string which will contain all the characters in t. | Hard | Detailed Solution |
| Valid Anagram | Determine if two strings are anagrams of each other. | Easy | Detailed Solution |
| Group Anagrams | Given an array of strings, group the anagrams together. | Medium | Detailed Solution |
| Valid Parentheses | Given a string containing just the characters '(', ')', ', ', '[' and ']', determine if the input string is valid. | Easy | Detailed Solution |
| Valid Palindrome | Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. | Easy | Detailed Solution |
| Longest Palindromic Substring | Given a string, return the longest palindromic substring. | Medium | Detailed Solution |
| Palindromic Substrings | Given a string, count the number of distinct palindromic substrings in it. | Medium | Detailed 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. | Medium | Detailed Solution |
Tree
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Maximum Depth of Binary Tree | Given a binary tree, find its maximum depth. | Easy | Detailed Solution |
| Same Tree | Given two binary trees, write a function to check if they are the same or not. | Easy | Detailed Solution |
| Invert/Flip Binary Tree | Invert a binary tree. | Easy | Detailed Solution |
| Binary Tree Maximum Path Sum | Given a non-empty binary tree, find the maximum path sum. | Hard | Detailed Solution |
| Binary Tree Level Order Traversal | Given a binary tree, return the level order traversal of its nodes' values. | Medium | Detailed Solution |
| Serialize and Deserialize Binary Tree | Design an algorithm to serialize and deserialize a binary tree. | Hard | Detailed Solution |
| Subtree of Another Tree | Given 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. | Easy | Detailed Solution |
| Construct Binary Tree from Preorder and Inorder Traversal | Given preorder and inorder traversal of a tree, construct the binary tree. | Medium | Detailed Solution |
| Validate Binary Search Tree | Given a binary tree, determine if it is a valid binary search tree. | Medium | Detailed Solution |
| Kth Smallest Element in a BST | Given a binary search tree, write a function to find the kth smallest element in it. | Medium | Detailed Solution |
| Lowest Common Ancestor of BST | Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. | Medium | Detailed Solution |
| Implement Trie (Prefix Tree) | Implement a trie with insert, search, and startsWith methods. | Medium | Detailed Solution |
Heap
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Merge K Sorted Lists | Merge k sorted linked lists and return it as one sorted list. | Hard | Detailed Solution |
| Top K Frequent Elements | Given a non-empty array of integers, return the k most frequent elements. | Medium | Detailed Solution |
| Find Median from Data Stream | The median is the middle value in an ordered integer list. Write a function to find the median of the data stream. | Hard | Detailed Solution |
Miscellaneous
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Insert Delete GetRandom O(1) | Design a data structure that supports all following operations in average O(1) time. | Medium | Detailed Solution |
| LRU Cache | Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. | Medium | Detailed Solution |
| Word Break | Given 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. | Medium | Detailed Solution |
Advanced
| Problem | Description | Difficulty | Solution |
|---|---|---|---|
| Trapping Rain Water | Given 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. | Hard | Detailed Solution |
| N-Queens | The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. | Hard | Detailed Solution |
| LFU Cache | Design and implement a data structure for Least Frequently Used (LFU) cache. | Hard | Detailed 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!
