The “75 Most Important LeetCode DSA Questions,” often referred to as the Blind 75 (or variations like Grind 75), is the single most recommended curated list for coding interview preparation at top tech companies (FAANG, etc.).
This list is designed to cover the most common patterns and crucial data structures and algorithms (DSA) required to pass a technical interview. Here is a breakdown of the key topics and some of the most essential problems from the list, organized by category:
Array
1. Two Sum
Given an array of integers nums and an integer target, return the indices of the two numbers such that they add up to the target. You may assume that each input would have exactly one solution,
and you may not use the same element twice. You can return the answer in any order.
|
1 2 3 4 5 |
Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1]. |
2. Best Time to Buy and Sell Stock
You are given an array of prices where prices[i] is the price of a given stock on an ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0
|
1 2 3 4 5 |
Input: prices = [7,1,5,3,6,4] Output: 5 Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5. |
3. Contains Duplicate
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
|
1 2 3 4 |
Input: nums = [1,2,3,1] Output: true |
4. Product of Array Except Self
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[I]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation.
|
1 2 3 4 |
Input: nums = [1,2,3,4] Output: [24,12,8,6] |
5. Maximum Subarray
Given an integer array nums, find the subarray with the largest sum, and return its sum.
|
1 2 3 4 5 |
Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The subarray [4,-1,2,1] has the largest sum 6. |
|
1 2 3 4 5 |
Input: nums = [1] Output: 1 Explanation: The subarray [1] has the largest sum of 1. |
6. Maximum Product Subarray
Given an integer array nums, find a subarray that has the largest product, and return the product.
|
1 2 3 4 5 |
Input: nums = [2,3,-2,4] Output: 6 Explanation: [2,3] has the largest product 6. |
|
1 2 3 4 5 |
Input: nums = [-2,0,-1] Output: 0 Explanation: The result cannot be 2, because [-2,-1] is not a subarray. |
7. Find the Minimum in Rotated Sorted Array
Given the sorted rotated array nums of unique elements, return the minimum element of this array. You must write an algorithm that runs in O(log n) time.
|
1 2 3 4 5 |
Input: nums = [3,4,5,1,2] Output: 1 Explanation: The original array was [1,2,3,4,5] rotated 3 times. |
8. Search in Rotated Sorted Array
Given the array nums after the possible rotation and an integer target, return the index of the target if it is in nums, or -1 if it is not in nums. You must write an algorithm with O(log n) runtime complexity.
|
1 2 3 4 |
Input: nums = [4,5,6,7,0,1,2], target = 0 Output: 4 |
|
1 2 3 4 |
Input: nums = [4,5,6,7,0,1,2], target = 3 Output: -1 |
9. 3Sum
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]]. such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets.
|
1 2 3 4 5 6 7 8 9 10 11 |
Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] Explanation: nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0. nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0. nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0. The distinct triplets are [-1,0,1] and [-1,-1,2]. |
10. Container With Most Water
You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[I]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store.
|
1 2 3 4 5 |
Input: height = [1,8,6,2,5,4,8,3,7] Output: 49 Explanation: The above vertical lines are represented by an array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49. |
Matrix
1. Set Matrix Zeroes
Given an m x n integer matrix, if an element is 0, set its entire row and column to 0’s. You must do it in place.
|
1 2 3 4 |
Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] Output: [[1,0,1],[0,0,0],[1,0,1]] |
2. Spiral Matrix
Given an m x n matrix, return all elements of the matrix in spiral order.
|
1 2 3 4 |
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,4,5] |
3. Rotate Image
You are given an n x n 2D matrix representing an image, and you are to rotate the image by 90 degrees (clockwise). You must rotate the image in place, which means modifying the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
|
1 2 3 4 |
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [[7,4,1],[8,5,2],[9,6,3]] |
4. Word Search
Given an m x n grid of characters board and a string word, return true if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
|
1 2 3 4 |
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED" Output: true |
String
1. Longest Substring Without Repeating Characters
Given a string s, find the length of the longest substring without repeating characters.
|
1 2 3 4 5 |
Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with a length of 3. |
2. Longest Repeating Character Replacement
You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times.
Return the length of the longest substring containing the same letter you can get after performing the above operations.
|
1 2 3 4 5 |
Input: s = "ABAB", k = 2 Output: 4 Explanation: Replace the two 'A's with two 'B's or vice versa. |
3. Minimum Window Substring
Given two strings s and t of lengths m and n, respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string “”.
|
1 2 3 4 5 |
Input: s = "ADOBECODEBANC", t = "ABC" Output: "BANC" Explanation: The minimum window substring "BANC" includes 'A', 'B', and 'C' from string t. |
4. Valid Anagram
Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
|
1 2 3 4 |
Input: s = "anagram", t = "nagaram" Output: true |
|
1 2 3 4 |
Input: s = "rat", t = "car" Output: false |
5. Group Anagrams
Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
|
1 2 3 4 |
Input: strs = ["eat","tea","tan","ate","nat","bat"] Output: [["bat"],["nat","tan"],["ate","eat","tea"]] |
6. Valid Parentheses
Given a string s containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid. An input string is valid if:
- Open brackets must be closed by the same type of brackets.
- Open brackets must be closed in the correct order.
- Every close bracket has a corresponding open bracket of the same type.
|
1 2 3 4 |
Input: s = "()" Output: true |
|
1 2 3 4 |
Input: s = "()[]{}" Output: true |
7. Longest Palindromic Substring
Given a string s, return the longest palindromic substring in s.
|
1 2 3 4 5 |
Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer. |
|
1 2 3 4 |
Input: s = "cbbd" Output: "bb" |
8. Palindromic Substrings
Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.
|
1 2 3 4 5 |
Input: s = "abc" Output: 3 Explanation: Three palindromic strings: "a", "b", "c". |
|
1 2 3 4 5 |
Input: s = "aaa" Output: 6 Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa". |
9. Encode and Decode Strings
Design an algorithm to encode a list of strings into a string. The encoded string is then sent over the network and decoded back to the original list of strings. implement encode and decode
|
1 2 3 4 5 |
Input: [“lint”,“code”,“love”,“you”] Output: [“lint”,“code”,“love”,“you”] Explanation: One possible encode method is: “lint:;code:;love:;you” |
|
1 2 3 4 5 |
Input: [“we”, “say”, “:”, “yes”] Output: [“we”, “say”, “:”, “yes”] Explanation: One possible encode method is: “we:;say:;:::;yes” |
Linked List
1. Reverse Linked Lists
Given the head of a singly linked list, reverse the list, and return the reversed list.
|
1 2 3 4 |
Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] |
2. Linked List Cycle
Given the head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that the tail’s next pointer is connected to. Note that pos is not passed as a parameter. Return true if there is a cycle in the linked list. Otherwise, return false.
|
1 2 3 4 5 |
Input: head = [3,2,0,-4], pos = 1 Output: true Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed). |
3. Merge Two Sorted Lists
You are given the heads of two sorted linked lists, list1 and list2. Merge the two lists into a single sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list.
|
1 2 3 4 |
Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] |
4. Merge k Sorted Lists
You are given an array of k linked lists, each linked list is sorted in ascending order. Merge all the linked lists into one sorted linked list and return it.
|
1 2 3 4 5 6 7 8 9 10 11 |
Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] Explanation: The linked lists are: [ 1->4->5, 1->3->4, 2->6 ] merging them into one sorted list: 1->1->2->3->4->4->5->6 |
5. Remove Nth Node From End of List
Given the head of a linked list, remove the nth node from the end of the list and return its head.
|
1 2 3 4 |
Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] |
6. Reorder List
You are given the head of a singly linked list. The list can be represented as: L0 → L1 → … → Ln – 1 → Ln
Reorder the list to be in the following form: L0 → Ln → L1 → Ln – 1 → L2 → Ln – 2 → …
You may not modify the values in the list’s nodes. Only nodes themselves may be changed.
|
1 2 3 4 |
Input: head = [1,2,3,4] Output: [1,4,2,3] |

Leave a Comment