Hash Table Problems
Master hash table problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 457 problems in this category.
Total Problems: 457
Easy: 128
Medium: 265
Hard: 64
Showing 50 of 457 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Hash Table LeetCode Problems List
- 1. Two Sum - Easy - Hash TableGiven an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each inp... Topics: Array, Hash Table
- 3. Longest Substring Without Repeating Characters - Medium - Hash TableGiven a string s, find the length of the longest substring without duplicate characters.... Topics: Hash Table, String, Sliding Window
- 146. LRU Cache - Medium - Hash TableDesign a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initia... Topics: Hash Table, Linked List, Design, Doubly-Linked List
- 202. Happy Number - Easy - Hash TableWrite an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive intege... Topics: Hash Table, Math, Two Pointers
- 127. Word Ladder - Hard - Hash TableA transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk su... Topics: Hash Table, String, Breadth-First Search
- 49. Group Anagrams - Medium - Hash TableGiven an array of strings strs, group the anagrams together. You can return the answer in any order.... Topics: Array, Hash Table, String, Sorting
- 560. Subarray Sum Equals K - Medium - Hash TableGiven an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. A subarray is a contiguous non-empty seq... Topics: Array, Hash Table, Prefix Sum
- 347. Top K Frequent Elements - Medium - Hash TableGiven an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.... Topics: Array, Hash Table, Divide and Conquer, Sorting, Heap (Priority Queue), Bucket Sort, Counting, Quickselect
- 76. Minimum Window Substring - Hard - Hash TableGiven 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 duplicat... Topics: Hash Table, String, Sliding Window
- 409. Longest Palindrome - Easy - Hash TableGiven a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. L... Topics: Hash Table, String, Greedy
- 128. Longest Consecutive Sequence - Medium - Hash TableGiven an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n... Topics: Array, Hash Table, Union Find
- 141. Linked List Cycle - Easy - Hash TableGiven 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 ... Topics: Hash Table, Linked List, Two Pointers
- 721. Accounts Merge - Medium - Hash TableGiven a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the el... Topics: Array, Hash Table, String, Depth-First Search, Breadth-First Search, Union Find, Sorting
- 460. LFU Cache - Hard - Hash TableDesign and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class: LFUCache(int capacity) Initializes the ob... Topics: Hash Table, Linked List, Design, Doubly-Linked List
- 169. Majority Element - Easy - Hash TableGiven an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume t... Topics: Array, Hash Table, Divide and Conquer, Sorting, Counting
- 17. Letter Combinations of a Phone Number - Medium - Hash TableGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any... Topics: Hash Table, String, Backtracking
- 268. Missing Number - Easy - Hash TableGiven an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.... Topics: Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
- 208. Implement Trie (Prefix Tree) - Medium - Hash TableA trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are va... Topics: Hash Table, String, Design, Trie
- 1029. Vertical Order Traversal of a Binary Tree - Hard - Hash TableGiven the root of a binary tree, calculate the vertical order traversal of the binary tree. For each node at position (row, col), its left and right c... Topics: Hash Table, Tree, Depth-First Search, Breadth-First Search, Sorting, Binary Tree
- 41. First Missing Positive - Hard - Hash TableGiven an unsorted integer array nums. Return the smallest positive integer that is not present in nums. You must implement an algorithm that runs in O... Topics: Array, Hash Table
- 383. Ransom Note - Easy - Hash TableGiven two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. Each l... Topics: Hash Table, String, Counting
- 138. Copy List with Random Pointer - Medium - Hash TableA linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null. Cons... Topics: Hash Table, Linked List
- 242. Valid Anagram - Easy - Hash TableGiven two strings s and t, return true if t is an anagram of s, and false otherwise.... Topics: Hash Table, String, Sorting
- 442. Find All Duplicates in an Array - Medium - Hash TableGiven an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears at most twice, return an array... Topics: Array, Hash Table
- 105. Construct Binary Tree from Preorder and Inorder Traversal - Medium - Hash TableGiven two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the sa... Topics: Array, Hash Table, Divide and Conquer, Tree, Binary Tree
- 2406. Decode the Message - Easy - Hash TableYou are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows... Topics: Hash Table, String
- 567. Permutation in String - Medium - Hash TableGiven two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutatio... Topics: Hash Table, Two Pointers, String, Sliding Window
- 13. Roman to Integer - Easy - Hash TableRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10... Topics: Hash Table, Math, String
- 133. Clone Graph - Medium - Hash TableGiven a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) an... Topics: Hash Table, Depth-First Search, Breadth-First Search, Graph
- 653. Two Sum IV - Input is a BST - Easy - Hash TableGiven the root of a binary search tree and an integer k, return true if there exist two elements in the BST such that their sum is equal to k, or fals... Topics: Hash Table, Two Pointers, Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree
- 160. Intersection of Two Linked Lists - Easy - Hash TableGiven the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersec... Topics: Hash Table, Linked List, Two Pointers
- 36. Valid Sudoku - Medium - Hash TableDetermine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the dig... Topics: Array, Hash Table, Matrix
- 106. Construct Binary Tree from Inorder and Postorder Traversal - Medium - Hash TableGiven two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the... Topics: Array, Hash Table, Divide and Conquer, Tree, Binary Tree
- 621. Task Scheduler - Medium - Hash TableYou are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n. Each CPU interval can be idle or allow the completion of ... Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue), Counting
- 496. Next Greater Element I - Easy - Hash TableThe next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two dis... Topics: Array, Hash Table, Stack, Monotonic Stack
- 2479. Meeting Rooms III - Hard - Hash TableYou are given an integer n. There are n rooms numbered from 0 to n - 1. You are given a 2D integer array meetings where meetings[i] = [starti, endi] m... Topics: Array, Hash Table, Sorting, Heap (Priority Queue), Simulation
- 940. Fruit Into Baskets - Medium - Hash TableYou are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where f... Topics: Array, Hash Table, Sliding Window
- 438. Find All Anagrams in a String - Medium - Hash TableGiven two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.... Topics: Hash Table, String, Sliding Window
- 355. Design Twitter - Medium - Hash TableDesign a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the ... Topics: Hash Table, Linked List, Design, Heap (Priority Queue)
- 965. Unique Email Addresses - Easy - Hash TableEvery valid email consists of a local name and a domain name, separated by the '@' sign. Besides lowercase letters, the email may contain one or more ... Topics: Array, Hash Table, String
- 720. Longest Word in Dictionary - Medium - Hash TableGiven an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by othe... Topics: Array, Hash Table, String, Trie, Sorting
- 3934. Coupon Code Validator - Easy - Hash TableYou are given three arrays of length n that describe the properties of n coupons: code, businessLine, and isActive. The ith coupon has: code[i]: a str... Topics: Array, Hash Table, String, Sorting
- 424. Longest Repeating Character Replacement - Medium - Hash TableYou 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 ... Topics: Hash Table, String, Sliding Window
- 387. First Unique Character in a String - Easy - Hash TableGiven a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.... Topics: Hash Table, String, Queue, Counting
- 817. Design HashMap - Easy - Hash TableDesign a HashMap without using any built-in hash table libraries. Implement the MyHashMap class: MyHashMap() initializes the object with an empty map.... Topics: Array, Hash Table, Linked List, Design, Hash Function
- 380. Insert Delete GetRandom O(1) - Medium - Hash TableImplement the RandomizedSet class: RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not ... Topics: Array, Hash Table, Math, Design, Randomized
- 217. Contains Duplicate - Easy - Hash TableGiven an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.... Topics: Array, Hash Table, Sorting
- 822. Unique Morse Code Words - Easy - Hash TableInternational Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: 'a' maps to ".-", 'b' map... Topics: Array, Hash Table, String
- 37. Sudoku Solver - Hard - Hash TableWrite a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9... Topics: Array, Hash Table, Backtracking, Matrix
- 12. Integer to Roman - Medium - Hash TableSeven different symbols represent Roman numerals with the following values: Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Roman numerals are forme... Topics: Hash Table, Math, String
- 753. Open the Lock - Medium - Hash TableYou have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rota... Topics: Array, Hash Table, String, Breadth-First Search
- 139. Word Break - Medium - Hash TableGiven a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary wor... Topics: Array, Hash Table, String, Dynamic Programming, Trie, Memoization
- 336. Palindrome Pairs - Hard - Hash TableYou are given a 0-indexed array of unique strings words. A palindrome pair is a pair of integers (i, j) such that: 0 <= i, j < words.length, i != j, a... Topics: Array, Hash Table, String, Trie
- 1960. Check if the Sentence Is Pangram - Easy - Hash TableA pangram is a sentence where every letter of the English alphabet appears at least once. Given a string sentence containing only lowercase English le... Topics: Hash Table, String
- 349. Intersection of Two Arrays - Easy - Hash TableGiven two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the resu... Topics: Array, Hash Table, Two Pointers, Binary Search, Sorting
- 523. Continuous Subarray Sum - Medium - Hash TableGiven an integer array nums and an integer k, return true if nums has a good subarray or false otherwise. A good subarray is a subarray where: its len... Topics: Array, Hash Table, Math, Prefix Sum
- 126. Word Ladder II - Hard - Hash TableA transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk su... Topics: Hash Table, String, Backtracking, Breadth-First Search
- 1447. Jump Game IV - Hard - Hash TableGiven an array of integers arr, you are initially positioned at the first index of the array. In one step you can jump from index i to index: i + 1 wh... Topics: Array, Hash Table, Breadth-First Search
- 952. Word Subsets - Medium - Hash TableYou are given two string arrays words1 and words2. A string b is a subset of string a if every letter in b occurs in a including multiplicity. For exa... Topics: Array, Hash Table, String
- 350. Intersection of Two Arrays II - Easy - Hash TableGiven two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in b... Topics: Array, Hash Table, Two Pointers, Binary Search, Sorting
- 290. Word Pattern - Easy - Hash TableGiven a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in... Topics: Hash Table, String
- 433. Minimum Genetic Mutation - Medium - Hash TableA gene string can be represented by an 8-character long string, with choices from 'A', 'C', 'G', and 'T'. Suppose we need to investigate a mutation fr... Topics: Hash Table, String, Breadth-First Search
- 205. Isomorphic Strings - Easy - Hash TableGiven two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All o... Topics: Hash Table, String
- 3267. Find Longest Special Substring That Occurs Thrice I - Medium - Hash TableYou are given a string s that consists of lowercase English letters. A string is called special if it is made up of only a single character. For examp... Topics: Hash Table, String, Binary Search, Sliding Window, Counting
- 398. Random Pick Index - Medium - Hash TableGiven an integer array nums with possible duplicates, randomly output the index of a given target number. You can assume that the given target number ... Topics: Hash Table, Math, Reservoir Sampling, Randomized
- 920. Uncommon Words from Two Sentences - Easy - Hash TableA sentence is a string of single-space separated words where each word consists only of lowercase letters. A word is uncommon if it appears exactly on... Topics: Hash Table, String, Counting
- 990. Verifying an Alien Dictionary - Easy - Hash TableIn an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some perm... Topics: Array, Hash Table, String
- 837. Most Common Word - Easy - Hash TableGiven a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at... Topics: Array, Hash Table, String, Counting
- 73. Set Matrix Zeroes - Medium - Hash TableGiven an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's. You must do it in place.... Topics: Array, Hash Table, Matrix
- 2778. Frequency Tracker - Medium - Hash TableDesign a data structure that keeps track of the values in it and answers some queries regarding their frequencies. Implement the FrequencyTracker clas... Topics: Hash Table, Design
- 142. Linked List Cycle II - Medium - Hash TableGiven the head of a linked list, return the node where the cycle begins. If there is no cycle, return null. There is a cycle in a linked list if there... Topics: Hash Table, Linked List, Two Pointers
- 3863. Power Grid Maintenance - Medium - Hash TableYou are given an integer c representing c power stations, each with a unique identifier id from 1 to c (1‑based indexing). These stations are intercon... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph, Heap (Priority Queue), Ordered Set
- 726. Number of Atoms - Hard - Hash TableGiven a string formula representing a chemical formula, return the count of each atom. The atomic element always starts with an uppercase character, t... Topics: Hash Table, String, Stack, Sorting
- 893. All Nodes Distance K in Binary Tree - Medium - Hash TableGiven the root of a binary tree, the value of a target node target, and an integer k, return an array of the values of all nodes that have a distance ... Topics: Hash Table, Tree, Depth-First Search, Breadth-First Search, Binary Tree
- 3847. Minimum Swaps to Sort by Digit Sum - Medium - Hash TableYou are given an array nums of distinct positive integers. You need to sort the array in increasing order based on the sum of the digits of each numbe... Topics: Array, Hash Table, Sorting
- 140. Word Break II - Hard - Hash TableGiven a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all ... Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Trie, Memoization
- 525. Contiguous Array - Medium - Hash TableGiven a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.... Topics: Array, Hash Table, Prefix Sum
- 1635. Number of Good Pairs - Easy - Hash TableGiven an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j.... Topics: Array, Hash Table, Math, Counting
- 299. Bulls and Cows - Medium - Hash TableYou are playing the Bulls and Cows game with your friend. You write down a secret number and ask your friend to guess what the number is. When your fr... Topics: Hash Table, String, Counting
- 2552. Maximum Sum of Distinct Subarrays With Length K - Medium - Hash TableYou are given an integer array nums and an integer k. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions: T... Topics: Array, Hash Table, Sliding Window
- 454. 4Sum II - Medium - Hash TableGiven four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that: 0 <= i, j, k, l < n nums... Topics: Array, Hash Table
- 2444. Longest Ideal Subsequence - Medium - Hash TableYou are given a string s consisting of lowercase letters and an integer k. We call a string t ideal if the following conditions are satisfied: t is a ... Topics: Hash Table, String, Dynamic Programming
- 381. Insert Delete GetRandom O(1) - Duplicates allowed - Hard - Hash TableRandomizedCollection is a data structure that contains a collection of numbers, possibly duplicates (i.e., a multiset). It should support inserting an... Topics: Array, Hash Table, Math, Design, Randomized
- 395. Longest Substring with At Least K Repeating Characters - Medium - Hash TableGiven a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is grea... Topics: Hash Table, String, Divide and Conquer, Sliding Window
- 1044. Find Common Characters - Easy - Hash TableGiven a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the ... Topics: Array, Hash Table, String
- 1106. Escape a Large Maze - Hard - Hash TableThere is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y). We start at the source = [sx, sy] square an... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search
- 3573. Count Substrings That Can Be Rearranged to Contain a String I - Medium - Hash TableYou are given two strings word1 and word2. A string x is called valid if x can be rearranged to have word2 as a prefix. Return the total number of val... Topics: Hash Table, String, Sliding Window
- 451. Sort Characters By Frequency - Medium - Hash TableGiven a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears... Topics: Hash Table, String, Sorting, Heap (Priority Queue), Bucket Sort, Counting
- 807. Custom Sort String - Medium - Hash TableYou are given two strings order and s. All the characters of order are unique and were sorted in some custom order previously. Permute the characters ... Topics: Hash Table, String, Sorting
- 2378. Sender With Largest Word Count - Medium - Hash TableYou have a chat log of n messages. You are given two string arrays messages and senders where messages[i] is a message sent by senders[i]. A message i... Topics: Array, Hash Table, String, Counting
- 659. Split Array into Consecutive Subsequences - Medium - Hash TableYou are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subsequences su... Topics: Array, Hash Table, Greedy, Heap (Priority Queue)
- 2599. Take K of Each Character From Left and Right - Medium - Hash TableYou are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost ch... Topics: Hash Table, String, Sliding Window
- 457. Circular Array Loop - Medium - Hash TableYou are playing a game involving a circular array of non-zero integers nums. Each nums[i] denotes the number of indices forward/backward you must move... Topics: Array, Hash Table, Two Pointers
- 1272. Invalid Transactions - Medium - Hash TableA transaction is possibly invalid if: the amount exceeds $1000, or; if it occurs within (and including) 60 minutes of another transaction with the sam... Topics: Array, Hash Table, String, Sorting
- 797. Rabbits in Forest - Medium - Hash TableThere is a forest with an unknown number of rabbits. We asked n rabbits "How many rabbits have the same color as you?" and collected the answers in an... Topics: Array, Hash Table, Math, Greedy
- 1460. Number of Substrings Containing All Three Characters - Medium - Hash TableGiven a string s consisting only of characters a, b and c. Return the number of substrings containing at least one occurrence of all these characters ... Topics: Hash Table, String, Sliding Window
- 782. Jewels and Stones - Easy - Hash TableYou're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is... Topics: Hash Table, String
- 3265. Maximum Good Subarray Sum - Medium - Hash TableYou are given an array nums of length n and a positive integer k. A subarray of nums is called good if the absolute difference between its first and l... Topics: Array, Hash Table, Prefix Sum
- 1039. Find the Town Judge - Easy - Hash TableIn a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, the... Topics: Array, Hash Table, Graph
- 2362. Minimum Rounds to Complete All Tasks - Medium - Hash TableYou are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3... Topics: Array, Hash Table, Greedy, Counting
- 1023. Time Based Key-Value Store - Medium - Hash TableDesign a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at ... Topics: Hash Table, String, Binary Search, Design
- 3329. Find the Length of the Longest Common Prefix - Medium - Hash TableYou are given two arrays with positive integers arr1 and arr2. A prefix of a positive integer is an integer formed by one or more of its digits, start... Topics: Array, Hash Table, String, Trie
- 816. Design HashSet - Easy - Hash TableDesign a HashSet without using any built-in hash table libraries. Implement MyHashSet class: void add(key) Inserts the value key into the HashSet. boo... Topics: Array, Hash Table, Linked List, Design, Hash Function
- 2502. Sort the People - Easy - Hash TableYou are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n. For each index... Topics: Array, Hash Table, String, Sorting
- 833. Bus Routes - Hard - Hash TableYou are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever. For example, if routes[0] = [1,... Topics: Array, Hash Table, Breadth-First Search
- 1459. Apply Discount Every n Orders - Medium - Hash TableThere is a supermarket that is frequented by many customers. The products sold at the supermarket are represented as two parallel integer arrays produ... Topics: Array, Hash Table, Design
- 768. Partition Labels - Medium - Hash TableYou are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example,... Topics: Hash Table, Two Pointers, String, Greedy
- 1319. Unique Number of Occurrences - Easy - Hash TableGiven an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise.... Topics: Array, Hash Table
- 2161. Stock Price Fluctuation - Medium - Hash TableYou are given a stream of records about a particular stock. Each record contains a timestamp and the corresponding price of the stock at that timestam... Topics: Hash Table, Design, Heap (Priority Queue), Data Stream, Ordered Set
- 1798. Max Number of K-Sum Pairs - Medium - Hash TableYou are given an integer array nums and an integer k. In one operation, you can pick two numbers from the array whose sum equals k and remove them fro... Topics: Array, Hash Table, Two Pointers, Sorting
- 229. Majority Element II - Medium - Hash TableGiven an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.... Topics: Array, Hash Table, Sorting, Counting
- 2186. Count Vowel Substrings of a String - Easy - Hash TableA substring is a contiguous (non-empty) sequence of characters within a string. A vowel substring is a substring that only consists of vowels ('a', 'e... Topics: Hash Table, String
- 1353. Find Resultant Array After Removing Anagrams - Easy - Hash TableYou are given a 0-indexed string array words, where words[i] consists of lowercase English letters. In one operation, select any index i such that 0 <... Topics: Array, Hash Table, String, Sorting
- 2605. Count Anagrams - Hard - Hash TableYou are given a string s containing one or more words. Every consecutive pair of words is separated by a single space ' '. A string t is an anagram of... Topics: Hash Table, Math, String, Combinatorics, Counting
- 389. Find the Difference - Easy - Hash TableYou are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the le... Topics: Hash Table, String, Bit Manipulation, Sorting
- 219. Contains Duplicate II - Easy - Hash TableGiven an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(... Topics: Array, Hash Table, Sliding Window
- 966. Binary Subarrays With Sum - Medium - Hash TableGiven a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. A subarray is a contiguous part of the array.... Topics: Array, Hash Table, Sliding Window, Prefix Sum
- 554. Brick Wall - Medium - Hash TableThere is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit... Topics: Array, Hash Table
- 421. Maximum XOR of Two Numbers in an Array - Medium - Hash TableGiven an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.... Topics: Array, Hash Table, Bit Manipulation, Trie
- 1055. Pairs of Songs With Total Durations Divisible by 60 - Medium - Hash TableYou are given a list of songs where the ith song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration... Topics: Array, Hash Table, Counting
- 2428. Equal Row and Column Pairs - Medium - Hash TableGiven a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal. A row and column pair is co... Topics: Array, Hash Table, Matrix, Simulation
- 870. Magic Squares In Grid - Medium - Hash TableA 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Gi... Topics: Array, Hash Table, Math, Matrix
- 391. Perfect Rectangle - Hard - Hash TableGiven an array rectangles where rectangles[i] = [xi, yi, ai, bi] represents an axis-aligned rectangle. The bottom-left point of the rectangle is (xi, ... Topics: Array, Hash Table, Math, Geometry, Line Sweep
- 1400. Find Winner on a Tic Tac Toe Game - Easy - Hash TableTic-tac-toe is played by two players A and B on a 3 x 3 grid. The rules of Tic-Tac-Toe are: Players take turns placing characters into empty squares '... Topics: Array, Hash Table, Matrix, Simulation
- 2204. Find Subsequence of Length K With the Largest Sum - Easy - Hash TableYou are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum. Return any such sub... Topics: Array, Hash Table, Sorting, Heap (Priority Queue)
- 1129. Longest String Chain - Medium - Hash TableYou are given an array of words where each word consists of lowercase English letters. wordA is a predecessor of wordB if and only if we can insert ex... Topics: Array, Hash Table, Two Pointers, String, Dynamic Programming, Sorting
- 697. Degree of an Array - Easy - Hash TableGiven a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your t... Topics: Array, Hash Table
- 931. Maximum Frequency Stack - Hard - Hash TableDesign a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: Freq... Topics: Hash Table, Stack, Design, Ordered Set
- 2721. Sum of Distances - Medium - Hash TableYou are given a 0-indexed integer array nums. There exists an array arr of length nums.length, where arr[i] is the sum of |i - j| over all j such that... Topics: Array, Hash Table, Prefix Sum
- 746. Prefix and Suffix Search - Hard - Hash TableDesign a special dictionary that searches the words in it by a prefix and a suffix. Implement the WordFilter class: WordFilter(string[] words) Initial... Topics: Array, Hash Table, String, Design, Trie
- 1392. Find the Difference of Two Arrays - Easy - Hash TableGiven two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where: answer[0] is a list of all distinct integers in nums1 which ... Topics: Array, Hash Table
- 2169. Simple Bank System - Medium - Hash TableYou have been tasked with writing a program for a popular bank that will automate all its incoming transactions (transfer, deposit, and withdraw). The... Topics: Array, Hash Table, Design, Simulation
- 149. Max Points on a Line - Hard - Hash TableGiven an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same stra... Topics: Array, Hash Table, Math, Geometry
- 691. Stickers to Spell Word - Hard - Hash TableWe are given n different types of stickers. Each sticker has a lowercase English word on it. You would like to spell out the given string target by cu... Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- 480. Sliding Window Median - Hard - Hash TableThe median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the... Topics: Array, Hash Table, Sliding Window, Heap (Priority Queue)
- 1016. Subarray Sums Divisible by K - Medium - Hash TableGiven an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k. A subarray is a contiguous part... Topics: Array, Hash Table, Prefix Sum
- 781. Basic Calculator IV - Hard - Hash TableGiven an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]... Topics: Hash Table, Math, String, Stack, Recursion
- 535. Encode and Decode TinyURL - Medium - Hash TableNote: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as http... Topics: Hash Table, String, Design, Hash Function
- 3197. Maximum Strong Pair XOR II - Hard - Hash TableYou are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition: |x - y| <= min(x, y) Y... Topics: Array, Hash Table, Bit Manipulation, Trie, Sliding Window
- 1238. Alphabet Board Path - Medium - Hash TableOn an alphabet board, we start at position (0, 0), corresponding to character board[0][0]. Here, board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy",... Topics: Hash Table, String
- 842. Card Flipping Game - Medium - Hash TableYou are given two 0-indexed integer arrays fronts and backs of length n, where the ith card has the positive integer fronts[i] printed on the front an... Topics: Array, Hash Table
- 690. Employee Importance - Medium - Hash TableYou have a data structure of employee information, including the employee's unique ID, importance value, and direct subordinates' IDs. You are given a... Topics: Array, Hash Table, Tree, Depth-First Search, Breadth-First Search
- 976. Minimum Area Rectangle - Medium - Hash TableYou are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from these points, ... Topics: Array, Hash Table, Math, Geometry, Sorting
- 3437. Maximum Total Damage With Spell Casting - Medium - Hash TableA magician has various spells. You are given an array power, where each element represents the damage of a spell. Multiple spells can have the same da... Topics: Array, Hash Table, Two Pointers, Binary Search, Dynamic Programming, Sorting, Counting
- 3797. Design Spreadsheet - Medium - Hash TableA spreadsheet is a grid with 26 columns (labeled from 'A' to 'Z') and a given number of rows. Each cell in the spreadsheet can hold an integer value b... Topics: Array, Hash Table, String, Design, Matrix
- 906. Walking Robot Simulation - Medium - Hash TableA robot on an infinite XY-plane starts at point (0, 0) facing north. The robot receives an array of integers commands, which represents a sequence of ... Topics: Array, Hash Table, Simulation
- 2483. Task Scheduler II - Medium - Hash TableYou are given a 0-indexed array of positive integers tasks, representing tasks that need to be completed in order, where tasks[i] represents the type ... Topics: Array, Hash Table, Simulation
- 3206. Find Common Elements Between Two Arrays - Easy - Hash TableYou are given two integer arrays nums1 and nums2 of sizes n and m, respectively. Calculate the following values: answer1 : the number of indices i suc... Topics: Array, Hash Table
- 2433. Best Poker Hand - Easy - Hash TableYou are given an integer array ranks and a character array suits. You have 5 cards where the ith card has a rank of ranks[i] and a suit of suits[i]. T... Topics: Array, Hash Table, Counting
- 1547. Destination City - Easy - Hash TableYou are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination ... Topics: Array, Hash Table, String
- 575. Distribute Candies - Easy - Hash TableAlice has n candies, where the ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor. The doctor a... Topics: Array, Hash Table
- 2475. Largest Palindromic Number - Medium - Hash TableYou are given a string num consisting of digits only. Return the largest palindromic integer (in the form of a string) that can be formed using digits... Topics: Hash Table, String, Greedy, Counting
- 3455. Minimum Length of String After Operations - Medium - Hash TableYou are given a string s. You can perform the following process on s any number of times: Choose an index i in the string such that there is at least ... Topics: Hash Table, String, Counting
- 1741. Sort Array by Increasing Frequency - Easy - Hash TableGiven an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, ... Topics: Array, Hash Table, Sorting
- 1777. Determine if Two Strings Are Close - Medium - Hash TableTwo strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters. F... Topics: Hash Table, String, Sorting, Counting
- 2461. Amount of Time for Binary Tree to Be Infected - Medium - Hash TableYou are given the root of a binary tree with unique values, and an integer start. At minute 0, an infection starts from the node with value start. Eac... Topics: Hash Table, Tree, Depth-First Search, Breadth-First Search, Binary Tree
- 166. Fraction to Recurring Decimal - Medium - Hash TableGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating... Topics: Hash Table, Math, String
- 1776. Minimum Operations to Reduce X to Zero - Medium - Hash TableYou are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array num... Topics: Array, Hash Table, Binary Search, Sliding Window, Prefix Sum
- 448. Find All Numbers Disappeared in an Array - Easy - Hash TableGiven an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in ... Topics: Array, Hash Table
- 648. Replace Words - Medium - Hash TableIn English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word derivative. For... Topics: Array, Hash Table, String, Trie
- 2679. Count Distinct Numbers on Board - Easy - Hash TableYou are given a positive integer n, that is initially placed on a board. Every day, for 109 days, you perform the following procedure: For each number... Topics: Array, Hash Table, Math, Simulation
- 1034. Subarrays with K Different Integers - Hard - Hash TableGiven an integer array nums and an integer k, return the number of good subarrays of nums. A good array is an array where the number of different inte... Topics: Array, Hash Table, Sliding Window, Counting
- 1848. Sum of Unique Elements - Easy - Hash TableYou are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array. Return the sum of all the... Topics: Array, Hash Table, Counting
- 2609. Distinct Prime Factors of Product of Array - Medium - Hash TableGiven an array of positive integers nums, return the number of distinct prime factors in the product of the elements of nums. Note that: A number grea... Topics: Array, Hash Table, Math, Number Theory
- 2480. Find Subarrays With Equal Sum - Easy - Hash TableGiven a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum. Note that the two subarrays must begin a... Topics: Array, Hash Table
- 2254. Check if Every Row and Column Contains All Numbers - Easy - Hash TableAn n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive). Given an n x n integer matrix matrix, return... Topics: Array, Hash Table, Matrix
- 749. Shortest Completing Word - Easy - Hash TableGiven a string licensePlate and an array of strings words, find the shortest completing word in words. A completing word is a word that contains all t... Topics: Array, Hash Table, String
- 3428. Find the XOR of Numbers Which Appear Twice - Easy - Hash TableYou are given an array nums, where each number in the array appears either once or twice. Return the bitwise XOR of all the numbers that appear twice ... Topics: Array, Hash Table, Bit Manipulation
- 3227. Find Missing and Repeated Values - Easy - Hash TableYou are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appe... Topics: Array, Hash Table, Math, Matrix
- 2119. Minimum Number of Operations to Make Array Continuous - Hard - Hash TableYou are given an integer array nums. In one operation, you can replace any element in nums with any integer. nums is considered continuous if both of ... Topics: Array, Hash Table, Binary Search, Sliding Window
- 447. Number of Boomerangs - Medium - Hash TableYou are given n points in the plane that are all distinct, where points[i] = [xi, yi]. A boomerang is a tuple of points (i, j, k) such that the distan... Topics: Array, Hash Table, Math
- 3242. Count Elements With Maximum Frequency - Easy - Hash TableYou are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the ma... Topics: Array, Hash Table, Counting
- 1859. Change Minimum Characters to Satisfy One of Three Conditions - Medium - Hash TableYou are given two strings a and b that consist of lowercase letters. In one operation, you can change any character in a or b to any lowercase letter.... Topics: Hash Table, String, Counting, Prefix Sum
- 1043. Grid Illumination - Hard - Hash TableThere is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off. You are given a 2D array of lamp positions lamp... Topics: Array, Hash Table
- 862. Find And Replace in String - Medium - Hash TableYou are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel... Topics: Array, Hash Table, String, Sorting
- 2348. Count Number of Texts - Medium - Hash TableAlice is texting Bob using her phone. The mapping of digits to letters is shown in the figure below. In order to add a letter, Alice has to press the ... Topics: Hash Table, Math, String, Dynamic Programming
- 1786. Count the Number of Consistent Strings - Easy - Hash TableYou are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string... Topics: Array, Hash Table, String, Bit Manipulation, Counting
- 1995. Finding Pairs With a Certain Sum - Medium - Hash TableYou are given two integer arrays nums1 and nums2. You are tasked to implement a data structure that supports queries of two types: Add a positive inte... Topics: Array, Hash Table, Design
- 1482. How Many Numbers Are Smaller Than the Current Number - Easy - Hash TableGiven the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the num... Topics: Array, Hash Table, Sorting, Counting Sort
- 1890. Sum of Beauty of All Substrings - Medium - Hash TableThe beauty of a string is the difference in frequencies between the most frequent and least frequent characters. For example, the beauty of "abaacc" i... Topics: Hash Table, String, Counting
- 740. Delete and Earn - Medium - Hash TableYou are given an integer array nums. You want to maximize the number of points you get by performing the following operation any number of times: Pick... Topics: Array, Hash Table, Dynamic Programming
- 1370. Count Number of Nice Subarrays - Medium - Hash TableGiven an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. Return the number of nice sub... Topics: Array, Hash Table, Math, Sliding Window, Prefix Sum
- 925. Construct Binary Tree from Preorder and Postorder Traversal - Medium - Hash TableGiven two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the pos... Topics: Array, Hash Table, Divide and Conquer, Tree, Binary Tree
- 2312. Most Frequent Number Following Key In an Array - Easy - Hash TableYou are given a 0-indexed integer array nums. You are also given an integer key, which is present in nums. For every unique integer target in nums, co... Topics: Array, Hash Table, Counting
- 30. Substring with Concatenation of All Words - Hard - Hash TableYou are given a string s and an array of strings words. All the strings of words are of the same length. A concatenated string is a string that exactl... Topics: Hash Table, String, Sliding Window
- 2486. Most Frequent Even Element - Easy - Hash TableGiven an integer array nums, return the most frequent even element. If there is a tie, return the smallest one. If there is no such element, return -1... Topics: Array, Hash Table, Counting
- 2118. Maximum Earnings From Taxi - Medium - Hash TableThere are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you wa... Topics: Array, Hash Table, Binary Search, Dynamic Programming, Sorting
- 2429. Design a Food Rating System - Medium - Hash TableDesign a food rating system that can do the following: Modify the rating of a food item listed in the system. Return the highest-rated food item for a... Topics: Array, Hash Table, String, Design, Heap (Priority Queue), Ordered Set
- 3886. Count Number of Trapezoids I - Medium - Hash TableYou are given a 2D integer array points, where points[i] = [xi, yi] represents the coordinates of the ith point on the Cartesian plane. A horizontal t... Topics: Array, Hash Table, Math, Geometry
- 994. Prison Cells After N Days - Medium - Hash TableThere are 8 prison cells in a row and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to th... Topics: Array, Hash Table, Math, Bit Manipulation
- 645. Set Mismatch - Easy - Hash TableYou have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got dup... Topics: Array, Hash Table, Bit Manipulation, Sorting
- 1160. Letter Tile Possibilities - Medium - Hash TableYou have n tiles, where each tile has one letter tiles[i] printed on it. Return the number of possible non-empty sequences of letters you can make us... Topics: Hash Table, String, Backtracking, Counting
- 532. K-diff Pairs in an Array - Medium - Hash TableGiven an array of integers nums and an integer k, return the number of unique k-diff pairs in the array. A k-diff pair is an integer pair (nums[i], nu... Topics: Array, Hash Table, Two Pointers, Binary Search, Sorting
- 913. Random Flip Matrix - Medium - Hash TableThere is an m x n binary grid matrix with all the values set 0 initially. Design an algorithm to randomly pick an index (i, j) where matrix[i][j] == 0... Topics: Hash Table, Math, Reservoir Sampling, Randomized
- 3897. Count Number of Trapezoids II - Hard - Hash TableYou are given a 2D integer array points where points[i] = [xi, yi] represents the coordinates of the ith point on the Cartesian plane. Return the numb... Topics: Array, Hash Table, Math, Geometry
- 3412. Permutation Difference between Two Strings - Easy - Hash TableYou are given two strings s and t such that every character occurs at most once in s and t is a permutation of s. The permutation difference between s... Topics: Hash Table, String
- 187. Repeated DNA Sequences - Medium - Hash TableThe DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. For example, "ACGAATTCCG" is a DNA sequence. When study... Topics: Hash Table, String, Bit Manipulation, Sliding Window, Rolling Hash, Hash Function
- 2777. Find the Distinct Difference Array - Easy - Hash TableYou are given a 0-indexed array nums of length n. The distinct difference array of nums is an array diff of length n such that diff[i] is equal to the... Topics: Array, Hash Table
- 3653. Maximum Subarray Sum With Length Divisible by K - Medium - Hash TableYou are given an array of integers nums and an integer k. Return the maximum sum of a subarray of nums, such that the size of the subarray is divisibl... Topics: Array, Hash Table, Prefix Sum
- 676. Implement Magic Dictionary - Medium - Hash TableDesign a data structure that is initialized with a list of different words. Provided a string, you should determine if you can change exactly one char... Topics: Hash Table, String, Depth-First Search, Design, Trie
- 3324. Split the Array - Easy - Hash TableYou are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that: nums1.length == nums2.length... Topics: Array, Hash Table, Counting
- 2060. Merge BSTs to Create Single BST - Hard - Hash TableYou are given n BST (binary search tree) root nodes for n separate BSTs stored in an array trees (0-indexed). Each BST in trees has at most 3 nodes, a... Topics: Hash Table, Binary Search, Tree, Depth-First Search, Binary Tree
- 2220. Find All Possible Recipes from Given Supplies - Medium - Hash TableYou have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name re... Topics: Array, Hash Table, String, Graph, Topological Sort
- 2147. The Score of Students Solving Math Expression - Hard - Hash TableYou are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of ... Topics: Array, Hash Table, Math, String, Dynamic Programming, Stack, Memoization
- 1469. Minimum Number of Steps to Make Two Strings Anagram - Medium - Hash TableYou are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character. Return the ... Topics: Hash Table, String, Counting
- 1866. Restore the Array From Adjacent Pairs - Medium - Hash TableThere is an integer array nums that consists of n unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements... Topics: Array, Hash Table, Depth-First Search
- 3446. Find the Number of Good Pairs I - Easy - Hash TableYou are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k. A pair (i, j) is called good ... Topics: Array, Hash Table
- 2334. Number of Flowers in Full Bloom - Hard - Hash TableYou are given a 0-indexed 2D integer array flowers, where flowers[i] = [starti, endi] means the ith flower will be in full bloom from starti to endi (... Topics: Array, Hash Table, Binary Search, Sorting, Prefix Sum, Ordered Set
- 894. Random Pick with Blacklist - Hard - Hash TableYou are given an integer n and an array of unique integers blacklist. Design an algorithm to pick a random integer in the range [0, n - 1] that is not... Topics: Array, Hash Table, Math, Binary Search, Sorting, Randomized
- 2306. Create Binary Tree From Descriptions - Medium - Hash TableYou are given a 2D integer array descriptions where descriptions[i] = [parenti, childi, isLefti] indicates that parenti is the parent of childi in a b... Topics: Array, Hash Table, Tree, Binary Tree
- 2856. Count Complete Subarrays in an Array - Medium - Hash TableYou are given an array nums consisting of positive integers. We call a subarray of an array complete if the following condition is satisfied: The numb... Topics: Array, Hash Table, Sliding Window
- 632. Smallest Range Covering Elements from K Lists - Hard - Hash TableYou have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists. We de... Topics: Array, Hash Table, Greedy, Sliding Window, Sorting, Heap (Priority Queue)
- 924. Fair Candy Swap - Easy - Hash TableAlice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of ... Topics: Array, Hash Table, Binary Search, Sorting
- 964. Minimize Malware Spread II - Hard - Hash TableYou are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph
- 2755. Extra Characters in a String - Medium - Hash TableYou are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that eac... Topics: Array, Hash Table, String, Dynamic Programming, Trie
- 1813. Maximum Erasure Value - Medium - Hash TableYou are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is... Topics: Array, Hash Table, Sliding Window
- 876. Hand of Straights - Medium - Hash TableAlice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize con... Topics: Array, Hash Table, Greedy, Sorting
- 2633. Minimum Cost to Split an Array - Hard - Hash TableYou are given an integer array nums and an integer k. Split the array into some number of non-empty subarrays. The cost of a split is the sum of the i... Topics: Array, Hash Table, Dynamic Programming, Counting
- 2044. Number of Wonderful Substrings - Medium - Hash TableA wonderful string is a string where at most one letter appears an odd number of times. For example, "ccjjc" and "abab" are wonderful, but "ab" is not... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 1249. Snapshot Array - Medium - Hash TableImplement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given len... Topics: Array, Hash Table, Binary Search, Design
- 1064. Smallest Integer Divisible by K - Medium - Hash TableGiven a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digi... Topics: Hash Table, Math
- 829. Subdomain Visit Count - Medium - Hash TableA website domain "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com" and... Topics: Array, Hash Table, String, Counting
- 1556. Make Two Arrays Equal by Reversing Subarrays - Easy - Hash TableYou are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are all... Topics: Array, Hash Table, Sorting
- 1363. Greatest English Letter in Upper and Lower Case - Easy - Hash TableGiven a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s. The returned lette... Topics: Hash Table, String, Enumeration
- 2707. Merge Two 2D Arrays by Summing Values - Easy - Hash TableYou are given two 2D integer arrays nums1 and nums2. nums1[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali. nums2[... Topics: Array, Hash Table, Two Pointers
- 2079. Delete Duplicate Folders in System - Hard - Hash TableDue to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute p... Topics: Array, Hash Table, String, Trie, Hash Function
- 2766. Find the Prefix Common Array of Two Arrays - Medium - Hash TableYou are given two 0-indexed integer permutations A and B of length n. A prefix common array of A and B is an array C such that C[i] is equal to the co... Topics: Array, Hash Table, Bit Manipulation
- 1282. Number of Valid Words for Each Puzzle - Hard - Hash TableWith respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For e... Topics: Array, Hash Table, String, Bit Manipulation, Trie
- 1830. Count Good Meals - Medium - Hash TableA good meal is a meal that contains exactly two different food items with a sum of deliciousness equal to a power of two. You can pick any two differe... Topics: Array, Hash Table
- 2117. Find Original Array From Doubled Array - Medium - Hash TableAn integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shu... Topics: Array, Hash Table, Greedy, Sorting
- 609. Find Duplicate File in System - Medium - Hash TableGiven a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files ... Topics: Array, Hash Table, String
- 1207. Delete Nodes And Return Forest - Medium - Hash TableGiven the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are left with a fo... Topics: Array, Hash Table, Tree, Depth-First Search, Binary Tree
- 1573. Find Two Non-overlapping Sub-arrays Each With Target Sum - Medium - Hash TableYou are given an array of integers arr and an integer target. You have to find two non-overlapping sub-arrays of arr each with a sum equal target. The... Topics: Array, Hash Table, Binary Search, Dynamic Programming, Sliding Window
- 3630. Total Characters in String After Transformations II - Hard - Hash TableYou are given a string s consisting of lowercase English letters, an integer t representing the number of transformations to perform, and an array num... Topics: Hash Table, Math, String, Dynamic Programming, Counting
- 984. Most Stones Removed with Same Row or Column - Medium - Hash TableOn a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it sha... Topics: Hash Table, Depth-First Search, Union Find, Graph
- 1775. Design an Ordered Stream - Easy - Hash TableThere is a stream of n (idKey, value) pairs arriving in an arbitrary order, where idKey is an integer between 1 and n and value is a string. No two pa... Topics: Array, Hash Table, Design, Data Stream
- 3349. Maximum Length Substring With Two Occurrences - Easy - Hash TableGiven a string s, return the maximum length of a substring such that it contains at most two occurrences of each character.... Topics: Hash Table, String, Sliding Window
- 3905. Partition String - Medium - Hash TableGiven a string s, partition it into unique segments according to the following procedure: Start building a segment beginning at index 0. Continue exte... Topics: Hash Table, String, Trie, Simulation
- 2332. Count Lattice Points Inside a Circle - Medium - Hash TableGiven a 2D integer array circles where circles[i] = [xi, yi, ri] represents the center (xi, yi) and radius ri of the ith circle drawn on a grid, retur... Topics: Array, Hash Table, Math, Geometry, Enumeration
- 2054. The Number of the Smallest Unoccupied Chair - Medium - Hash TableThere is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 ... Topics: Array, Hash Table, Heap (Priority Queue)
- 1112. Find Words That Can Be Formed by Characters - Easy - Hash TableYou are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be ... Topics: Array, Hash Table, String, Counting
- 2289. Minimum Operations to Make the Array Alternating - Medium - Hash TableYou are given a 0-indexed array nums consisting of n positive integers. The array nums is called alternating if: nums[i - 2] == nums[i], where 2 <= i ... Topics: Array, Hash Table, Greedy, Counting
- 3501. Delete Nodes From Linked List Present in Array - Medium - Hash TableYou are given an array of integers nums and the head of a linked list. Return the head of the modified linked list after removing all nodes from the l... Topics: Array, Hash Table, Linked List
- 1526. HTML Entity Parser - Medium - Hash TableHTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself. The sp... Topics: Hash Table, String
- 2979. Maximize the Profit as the Salesman - Medium - Hash TableYou are given an integer n representing the number of houses on a number line, numbered from 0 to n - 1. Additionally, you are given a 2D integer arra... Topics: Array, Hash Table, Binary Search, Dynamic Programming, Sorting
- 2888. Minimum Index of a Valid Split - Medium - Hash TableAn element x of an integer array arr of length m is dominant if more than half the elements of arr have a value of x. You are given a 0-indexed intege... Topics: Array, Hash Table, Sorting
- 1065. Binary String With Substrings Representing 1 To N - Medium - Hash TableGiven a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s... Topics: Hash Table, String, Bit Manipulation, Sliding Window
- 2603. Reward Top K Students - Medium - Hash TableYou are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. N... Topics: Array, Hash Table, String, Sorting, Heap (Priority Queue)
- 2833. Count Zero Request Servers - Medium - Hash TableYou are given an integer n denoting the total number of servers and a 2D 0-indexed integer array logs, where logs[i] = [server_id, time] denotes that ... Topics: Array, Hash Table, Sliding Window, Sorting
- 3594. Identify the Largest Outlier in an Array - Medium - Hash TableYou are given an integer array nums. This array contains n elements, where exactly n - 2 elements are special numbers. One of the remaining two elemen... Topics: Array, Hash Table, Counting, Enumeration
- 3225. Length of Longest Subarray With at Most K Frequency - Medium - Hash TableYou are given an integer array nums and an integer k. The frequency of an element x is the number of times it occurs in an array. An array is called g... Topics: Array, Hash Table, Sliding Window
- 692. Top K Frequent Words - Medium - Hash TableGiven an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest... Topics: Array, Hash Table, String, Trie, Sorting, Heap (Priority Queue), Bucket Sort, Counting
- 1145. Number of Submatrices That Sum to Target - Hard - Hash TableGiven a matrix and a target, return the number of non-empty submatrices that sum to target. A submatrix x1, y1, x2, y2 is the set of all cells matrix[... Topics: Array, Hash Table, Matrix, Prefix Sum
- 3788. Maximum Unique Subarray Sum After Deletion - Easy - Hash TableYou are given an integer array nums. You are allowed to delete any number of elements from nums without making it empty. After performing the deletion... Topics: Array, Hash Table, Greedy
- 869. Similar String Groups - Hard - Hash TableTwo strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct ... Topics: Array, Hash Table, String, Depth-First Search, Breadth-First Search, Union Find
- 1987. Substrings of Size Three with Distinct Characters - Easy - Hash TableA string is good if there are no repeated characters. Given a string s, return the number of good substrings of length three in s. Note tha... Topics: Hash Table, String, Sliding Window, Counting
- 1562. People Whose List of Favorite Companies Is Not a Subset of Another List - Medium - Hash TableGiven the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0). Return the indice... Topics: Array, Hash Table, String
- 3885. Count Special Triplets - Medium - Hash TableYou are given an integer array nums. A special triplet is defined as a triplet of indices (i, j, k) such that: 0 <= i < j < k < n, where n = nums.leng... Topics: Array, Hash Table, Counting
- 2889. Number of Black Blocks - Medium - Hash TableYou are given two integers m and n representing the dimensions of a 0-indexed m x n grid. You are also given a 0-indexed 2D integer matrix coordinates... Topics: Array, Hash Table, Enumeration
- 1001. N-Repeated Element in Size 2N Array - Easy - Hash TableYou are given an integer array nums with the following properties: nums.length == 2 * n. nums contains n + 1 unique elements. Exactly one element of n... Topics: Array, Hash Table
- 2356. Largest Combination With Bitwise AND Greater Than Zero - Medium - Hash TableThe bitwise AND of an array nums is the bitwise AND of all integers in nums. For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 ... Topics: Array, Hash Table, Bit Manipulation, Counting
- 2034. Minimum Absolute Difference Queries - Medium - Hash TableThe minimum absolute difference of an array a is defined as the minimum value of |a[i] - a[j]|, where 0 <= i < j < a.length and a[i] != a[j]. If all e... Topics: Array, Hash Table
- 3868. Find Maximum Area of a Triangle - Medium - Hash TableYou are given a 2D array coords of size n x 2, representing the coordinates of n points in an infinite Cartesian plane. Find twice the maximum area of... Topics: Array, Hash Table, Math, Greedy, Geometry, Enumeration
- 2615. Make Number of Distinct Characters Equal - Medium - Hash TableYou are given two 0-indexed strings word1 and word2. A move consists of choosing two indices i and j such that 0 <= i < word1.length and 0 <= j < word... Topics: Hash Table, String, Counting
- 1986. Largest Color Value in a Directed Graph - Hard - Hash TableThere is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1. You are given a string colors where colors[i] is a l... Topics: Hash Table, Dynamic Programming, Graph, Topological Sort, Memoization, Counting
- 2832. Find the Longest Equal Subarray - Medium - Hash TableYou are given a 0-indexed integer array nums and an integer k. A subarray is called equal if all of its elements are equal. Note that the empty subarr... Topics: Array, Hash Table, Binary Search, Sliding Window
- 1273. Compare Strings by Frequency of the Smallest Character - Medium - Hash TableLet the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 b... Topics: Array, Hash Table, String, Binary Search, Sorting
- 3388. Right Triangles - Medium - Hash TableYou are given a 2D boolean matrix grid. A collection of 3 elements of grid is a right triangle if one of its elements is in the same row with another ... Topics: Array, Hash Table, Math, Combinatorics, Counting
- 1038. Number of Squareful Arrays - Hard - Hash TableAn array is squareful if the sum of every pair of adjacent elements is a perfect square. Given an integer array nums, return the number of permutation... Topics: Array, Hash Table, Math, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 1905. Design Authentication Manager - Medium - Hash TableThere is an authentication system that works with authentication tokens. For each session, the user will receive a new authentication token that will ... Topics: Hash Table, Linked List, Design, Doubly-Linked List
- 3405. Count the Number of Special Characters II - Medium - Hash TableYou are given a string word. A letter c is called special if it appears both in lowercase and uppercase in word, and every lowercase occurrence of c a... Topics: Hash Table, String
- 900. Reordered Power of 2 - Medium - Hash TableYou are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero. Return true if ... Topics: Hash Table, Math, Sorting, Counting, Enumeration
- 3736. Find Valid Pair of Adjacent Digits in String - Easy - Hash TableYou are given a string s consisting only of digits. A valid pair is defined as two adjacent digits in s such that: The first digit is not equal to the... Topics: Hash Table, String, Counting
- 1433. Encrypt and Decrypt Strings - Hard - Hash TableYou are given a character array keys containing unique characters and a string array values containing strings of length 2. You are also given another... Topics: Array, Hash Table, String, Design, Trie
- 491. Non-decreasing Subsequences - Medium - Hash TableGiven an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may retu... Topics: Array, Hash Table, Backtracking, Bit Manipulation
- 1557. Check If a String Contains All Binary Codes of Size K - Medium - Hash TableGiven a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.... Topics: Hash Table, String, Bit Manipulation, Rolling Hash, Hash Function
- 1533. Display Table of Food Orders in a Restaurant - Medium - Hash TableGiven the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,... Topics: Array, Hash Table, String, Sorting, Ordered Set
- 2116. Count Number of Pairs With Absolute Difference K - Easy - Hash TableGiven an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k. The value of |x| is de... Topics: Array, Hash Table, Counting
- 3819. Count Covered Buildings - Medium - Hash TableYou are given a positive integer n, representing an n x n city. You are also given a 2D grid buildings, where buildings[i] = [x, y] denotes a unique b... Topics: Array, Hash Table, Sorting
- 960. Minimize Malware Spread - Hard - Hash TableYou are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph
- 3872. Find Most Frequent Vowel and Consonant - Easy - Hash TableYou are given a string s consisting of lowercase English letters ('a' to 'z'). Your task is to: Find the vowel (one of 'a', 'e', 'i', 'o', or 'u') wit... Topics: Hash Table, String, Counting
- 2023. Design Movie Rental System - Hard - Hash TableYou have a movie renting company consisting of n shops. You want to implement a renting system that supports searching for, booking, and returning mov... Topics: Array, Hash Table, Design, Heap (Priority Queue), Ordered Set
- 2215. Finding 3-Digit Even Numbers - Easy - Hash TableYou are given an integer array digits, where each element is a digit. The array may contain duplicates. You need to find all the unique integers that ... Topics: Array, Hash Table, Sorting, Enumeration
- 1915. Check if One String Swap Can Make Strings Equal - Easy - Hash TableYou are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different... Topics: Hash Table, String, Counting
- 1904. Second Largest Digit in a String - Easy - Hash TableGiven an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist. An alphanumeric string is a s... Topics: Hash Table, String
- 2177. Check Whether Two Strings are Almost Equivalent - Easy - Hash TableTwo strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 a... Topics: Hash Table, String, Counting
- 3434. Find the Number of Distinct Colors Among the Balls - Medium - Hash TableYou are given an integer limit and a 2D array queries of size n x 2. There are limit + 1 balls with distinct labels in the range [0, limit]. Initially... Topics: Array, Hash Table, Simulation
- 2025. Redistribute Characters to Make All Strings Equal - Easy - Hash TableYou are given an array of strings words (0-indexed). In one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and mo... Topics: Hash Table, String, Counting
- 2237. Longest Palindrome by Concatenating Two Letter Words - Medium - Hash TableYou are given an array of strings words. Each element of words consists of two lowercase English letters. Create the longest possible palindrome by se... Topics: Array, Hash Table, String, Greedy, Counting
- 3809. Properties Graph - Medium - Hash TableYou are given a 2D integer array properties having dimensions n x m and an integer k. Define a function intersect(a, b) that returns the number of dis... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph
- 264. Ugly Number II - Medium - Hash TableAn ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return the nth ugly number.... Topics: Hash Table, Math, Dynamic Programming, Heap (Priority Queue)
- 3850. Equal Sum Grid Partition II - Hard - Hash TableYou are given an m x n matrix grid of positive integers. Your task is to determine if it is possible to make either one horizontal or one vertical cut... Topics: Array, Hash Table, Matrix, Enumeration, Prefix Sum
- 2954. Maximum Sum of Almost Unique Subarray - Medium - Hash TableYou are given an integer array nums and two positive integers m and k. Return the maximum sum out of all almost unique subarrays of length k of nums. ... Topics: Array, Hash Table, Sliding Window
- 2677. Cousins in Binary Tree II - Medium - Hash TableGiven the root of a binary tree, replace the value of each node in the tree with the sum of all its cousins' values. Two nodes of a binary tree are co... Topics: Hash Table, Tree, Depth-First Search, Breadth-First Search, Binary Tree
- 3236. Smallest Missing Integer Greater Than Sequential Prefix Sum - Easy - Hash TableYou are given a 0-indexed array of integers nums. A prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular,... Topics: Array, Hash Table, Sorting
- 3250. Maximum Square Area by Removing Fences From a Field - Medium - Hash TableThere is a large (m - 1) x (n - 1) rectangular field with corners at (1, 1) and (m, n) containing some horizontal and vertical fences given in arrays ... Topics: Array, Hash Table, Enumeration
- 2892. Check if Array is Good - Easy - Hash TableYou are given an integer array nums. We consider an array good if it is a permutation of an array base[n]. base[n] = [1, 2, ..., n - 1, n, n] (in othe... Topics: Array, Hash Table, Sorting
- 2256. Count Words Obtained After Adding a Letter - Medium - Hash TableYou are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only. For each string in t... Topics: Array, Hash Table, String, Bit Manipulation, Sorting
- 2447. Merge Similar Items - Easy - Hash TableYou are given two 2D integer arrays, items1 and items2, representing two sets of items. Each array items has the following properties: items[i] = [val... Topics: Array, Hash Table, Sorting, Ordered Set
- 1473. Find the Longest Substring Containing Vowels in Even Counts - Medium - Hash TableGiven the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must ... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 2834. Relocate Marbles - Medium - Hash TableYou are given a 0-indexed integer array nums representing the initial positions of some marbles. You are also given two 0-indexed integer arrays moveF... Topics: Array, Hash Table, Sorting, Simulation
- 1297. Maximum Number of Balloons - Easy - Hash TableGiven a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. You can use each character in... Topics: Hash Table, String, Counting
- 2592. Minimum Total Cost to Make Arrays Unequal - Hard - Hash TableYou are given two 0-indexed integer arrays nums1 and nums2, of equal length n. In one operation, you can swap the values of any two indices of nums1. ... Topics: Array, Hash Table, Greedy, Counting
- 3335. Minimum Operations to Write the Letter Y on a Grid - Medium - Hash TableYou are given a 0-indexed n x n grid where n is odd, and grid[r][c] is 0, 1, or 2. We say that a cell belongs to the Letter Y if it belongs to one of ... Topics: Array, Hash Table, Matrix, Counting
- 2455. Node With Highest Edge Score - Medium - Hash TableYou are given a directed graph with n nodes labeled from 0 to n - 1, where each node has exactly one outgoing edge. The graph is represented by a give... Topics: Hash Table, Graph
- 3163. Subarrays Distinct Element Sum of Squares I - Easy - Hash TableYou are given a 0-indexed integer array nums. The distinct count of a subarray of nums is defined as: Let nums[i..j] be a subarray of nums consisting ... Topics: Array, Hash Table
- 3634. Find Mirror Score of a String - Medium - Hash TableYou are given a string s. We define the mirror of a letter in the English alphabet as its corresponding letter when the alphabet is reversed. For exam... Topics: Hash Table, String, Stack, Simulation
- 3384. Minimum Number of Operations to Make Word K-Periodic - Medium - Hash TableYou are given a string word of size n, and an integer k such that k divides n. In one operation, you can pick any two indices i and j, that are divisi... Topics: Hash Table, String, Counting
- 2442. Number of Arithmetic Triplets - Easy - Hash TableYou are given a 0-indexed, strictly increasing integer array nums and a positive integer diff. A triplet (i, j, k) is an arithmetic triplet if the fol... Topics: Array, Hash Table, Two Pointers, Enumeration
- 3933. Minimum Jumps to Reach End via Prime Teleportation - Medium - Hash TableYou are given an integer array nums of length n. You start at index 0, and your goal is to reach index n - 1. From any index i, you may perform one of... Topics: Array, Hash Table, Math, Breadth-First Search, Number Theory
- 2390. Naming a Company - Hard - Hash TableYou are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company... Topics: Array, Hash Table, String, Bit Manipulation, Enumeration
- 2436. Make Array Zero by Subtracting Equal Amounts - Easy - Hash TableYou are given a non-negative integer array nums. In one operation, you must: Choose a positive integer x such that x is less than or equal to the smal... Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue), Simulation
- 1554. Minimum Time to Collect All Apples in a Tree - Medium - Hash TableGiven an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one... Topics: Hash Table, Tree, Depth-First Search, Breadth-First Search
- 2978. Check if Strings Can be Made Equal With Operations II - Medium - Hash TableYou are given two strings s1 and s2, both of length n, consisting of lowercase English letters. You can apply the following operation on any of the tw... Topics: Hash Table, String, Sorting
- 2640. Maximum Number of Integers to Choose From a Range I - Medium - Hash TableYou are given an integer array banned and two integers n and maxSum. You are choosing some number of integers following the below rules: The chosen in... Topics: Array, Hash Table, Binary Search, Greedy, Sorting
- 1934. Evaluate the Bracket Pairs of a String - Medium - Hash TableYou are given a string s that contains some bracket pairs, with each pair containing a non-empty key. For example, in the string "(name)is(age)yearsol... Topics: Array, Hash Table, String
- 3456. Find the Maximum Length of a Good Subsequence I - Medium - Hash TableYou are given an integer array nums and a non-negative integer k. A sequence of integers seq is called good if there are at most k indices i in the ra... Topics: Array, Hash Table, Dynamic Programming
- 1699. Number of Ways Where Square of Number Is Equal to Product of Two Numbers - Medium - Hash TableGiven two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules: Type 1: Triplet (i, ... Topics: Array, Hash Table, Math, Two Pointers
- 1512. Design Underground System - Medium - Hash TableAn underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average ... Topics: Hash Table, String, Design
- 2520. Using a Robot to Print the Lexicographically Smallest String - Medium - Hash TableYou are given a string s and a robot that currently holds an empty string t. Apply one of the following operations until s and t are both empty: Remov... Topics: Hash Table, String, Stack, Greedy
- 1270. Dinner Plate Stacks - Hard - Hash TableYou have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. Impleme... Topics: Hash Table, Stack, Design, Heap (Priority Queue)
- 2293. Minimum Number of Steps to Make Two Strings Anagram II - Medium - Hash TableYou are given two strings s and t. In one step, you can append any character to either s or t. Return the minimum number of steps to make s and t anag... Topics: Hash Table, String, Counting
- 594. Longest Harmonious Subsequence - Easy - Hash TableWe define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array num... Topics: Array, Hash Table, Sliding Window, Sorting, Counting
- 3360. Minimum Deletions to Make String K-Special - Medium - Hash TableYou are given a string word and an integer k. We consider word to be k-special if |freq(word[i]) - freq(word[j])| <= k for all indices i and j in the ... Topics: Hash Table, String, Greedy, Sorting, Counting
- 896. Smallest Subtree with all the Deepest Nodes - Medium - Hash TableGiven the root of a binary tree, the depth of each node is the shortest distance to the root. Return the smallest subtree such that it contains all th... Topics: Hash Table, Tree, Depth-First Search, Breadth-First Search, Binary Tree
- 2902. Max Pair Sum in an Array - Easy - Hash TableYou are given an integer array nums. You have to find the maximum sum of a pair of numbers from nums such that the largest digit in both numbers is eq... Topics: Array, Hash Table
- 1925. Count Nice Pairs in an Array - Medium - Hash TableYou are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, re... Topics: Array, Hash Table, Math, Counting
- 3541. Report Spam Message - Medium - Hash TableYou are given an array of strings message and an array of strings bannedWords. An array of words is considered spam if there are at least two words in... Topics: Array, Hash Table, String
- 3212. Count the Number of Good Partitions - Hard - Hash TableYou are given a 0-indexed array nums consisting of positive integers. A partition of an array into one or more contiguous subarrays is called good if ... Topics: Array, Hash Table, Math, Combinatorics
- 1553. Count Triplets That Can Form Two Arrays of Equal XOR - Medium - Hash TableGiven an array of integers arr. We want to select three indices i, j and k where (0 <= i < j <= k < arr.length). Let's define a and b as follows: a = ... Topics: Array, Hash Table, Math, Bit Manipulation, Prefix Sum
- 1218. Lowest Common Ancestor of Deepest Leaves - Medium - Hash TableGiven the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary tree is a leaf if and only... Topics: Hash Table, Tree, Depth-First Search, Breadth-First Search, Binary Tree
- 432. All O`one Data Structure - Hard - Hash TableDesign a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts. Implement the AllOne class... Topics: Hash Table, Linked List, Design, Doubly-Linked List
- 1227. Number of Equivalent Domino Pairs - Easy - Hash TableGiven a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c)... Topics: Array, Hash Table, Counting
- 2561. Number of Distinct Averages - Easy - Hash TableYou are given a 0-indexed integer array nums of even length. As long as nums is not empty, you must repetitively: Find the minimum number in nums and ... Topics: Array, Hash Table, Two Pointers, Sorting
- 3356. Shortest Uncommon Substring in an Array - Medium - Hash TableYou are given an array arr of size n consisting of non-empty strings. Find a string array answer of size n such that: answer[i] is the shortest substr... Topics: Array, Hash Table, String, Trie
- 3034. Points That Intersect With Cars - Easy - Hash TableYou are given a 0-indexed 2D integer array nums representing the coordinates of the cars parking on a number line. For any index i, nums[i] = [starti,... Topics: Array, Hash Table, Prefix Sum
- 2139. Detect Squares - Medium - Hash TableYou are given a stream of points on the X-Y plane. Design an algorithm that: Adds new points from the stream into a data structure. Duplicate points a... Topics: Array, Hash Table, Design, Counting
- 3813. Smallest Palindromic Rearrangement II - Hard - Hash TableYou are given a palindromic string s and an integer k. Return the k-th lexicographically smallest palindromic permutation of s. If there are fewer tha... Topics: Hash Table, Math, String, Combinatorics, Counting
- 3754. Maximum Manhattan Distance After K Changes - Medium - Hash TableYou are given a string s consisting of the characters 'N', 'S', 'E', and 'W', where s[i] indicates movements in an infinite grid: 'N' : Move north by ... Topics: Hash Table, Math, String, Counting
- 2413. Smallest Number in Infinite Set - Medium - Hash TableYou have a set which contains all positive integers [1, 2, 3, 4, 5, ...]. Implement the SmallestInfiniteSet class: SmallestInfiniteSet() Initializes t... Topics: Hash Table, Design, Heap (Priority Queue), Ordered Set
- 3753. Maximum Difference Between Even and Odd Frequency I - Easy - Hash TableYou are given a string s consisting of lowercase English letters. Your task is to find the maximum difference diff = freq(a1) - freq(a2) between the f... Topics: Hash Table, String, Counting
- 508. Most Frequent Subtree Sum - Medium - Hash TableGiven the root of a binary tree, return the most frequent subtree sum. If there is a tie, return all the values with the highest frequency in any orde... Topics: Hash Table, Tree, Depth-First Search, Binary Tree
- 3141. Minimum Size Subarray in Infinite Array - Medium - Hash TableYou are given a 0-indexed array nums and an integer target. A 0-indexed array infinite_nums is generated by infinitely appending the elements of nums ... Topics: Array, Hash Table, Sliding Window, Prefix Sum
- 1873. Longest Nice Substring - Easy - Hash TableA string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice beca... Topics: Hash Table, String, Divide and Conquer, Bit Manipulation, Sliding Window
- 3534. Count Almost Equal Pairs I - Medium - Hash TableYou are given an array nums consisting of positive integers. We call two integers x and y in this problem almost equal if both integers can become equ... Topics: Array, Hash Table, Sorting, Counting, Enumeration
- 2884. Length of the Longest Valid Substring - Hard - Hash TableYou are given a string word and an array of strings forbidden. A string is called valid if none of its substrings are present in forbidden. Return the... Topics: Array, Hash Table, String, Sliding Window
- 1502. Construct K Palindrome Strings - Medium - Hash TableGiven a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.... Topics: Hash Table, String, Greedy, Counting
- 3837. Grid Teleportation Traversal - Medium - Hash TableYou are given a 2D character grid matrix of size m x n, represented as an array of strings, where matrix[i][j] represents the cell at the intersection... Topics: Array, Hash Table, Breadth-First Search, Matrix
- 2434. Design a Number Container System - Medium - Hash TableDesign a number container system that can do the following: Insert or Replace a number at the given index in the system. Return the smallest index for... Topics: Hash Table, Design, Heap (Priority Queue), Ordered Set
- 3914. Check if Any Element Has Prime Frequency - Easy - Hash TableYou are given an integer array nums. Return true if the frequency of any element of the array is prime, otherwise, return false. The frequency of an e... Topics: Array, Hash Table, Math, Counting, Number Theory
- 991. Array of Doubled Pairs - Medium - Hash TableGiven an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < l... Topics: Array, Hash Table, Greedy, Sorting
- 1722. Throne Inheritance - Medium - Hash TableA kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born. The ki... Topics: Hash Table, Tree, Depth-First Search, Design
- 3894. Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values - Medium - Hash TableYou are given two integer arrays x and y, each of length n. You must choose three distinct indices i, j, and k such that: x[i] != x[j] x[j] != x[k] x[... Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue)
- 3687. Longest Special Path - Hard - Hash TableYou are given an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1, represented by a 2D array edges of length n - 1, where edges[... Topics: Array, Hash Table, Tree, Depth-First Search, Prefix Sum
- 3445. Lexicographically Minimum String After Removing Stars - Medium - Hash TableYou are given a string s. It may contain any number of '*' characters. Your task is to remove all '*' characters. While there is a '*', do the followi... Topics: Hash Table, String, Stack, Greedy, Heap (Priority Queue)
- 2300. Construct String With Repeat Limit - Medium - Hash TableYou are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears ... Topics: Hash Table, String, Greedy, Heap (Priority Queue), Counting
- 2532. Remove Letter To Equalize Frequency - Easy - Hash TableYou are given a 0-indexed string word, consisting of lowercase English letters. You need to select one index and remove the letter at that index from ... Topics: Hash Table, String, Counting
- 3578. Construct 2D Grid Matching Graph Layout - Hard - Hash TableYou are given a 2D integer array edges representing an undirected graph having n nodes, where edges[i] = [ui, vi] denotes an edge between nodes ui and... Topics: Array, Hash Table, Graph, Matrix
- 3870. Minimum Moves to Clean the Classroom - Medium - Hash TableYou are given an m x n grid classroom where a student volunteer is tasked with cleaning up litter scattered around the room. Each cell in the grid is ... Topics: Array, Hash Table, Bit Manipulation, Breadth-First Search, Matrix
- 2174. Next Greater Numerically Balanced Number - Medium - Hash TableAn integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x. Given an integer n, ret... Topics: Hash Table, Math, Backtracking, Counting, Enumeration
- 2801. Difference of Number of Distinct Values on Diagonals - Medium - Hash TableGiven a 2D grid of size m x n, you should find the matrix answer of size m x n. The cell answer[r][c] is calculated by looking at the diagonal values ... Topics: Array, Hash Table, Matrix
- 3569. Count of Substrings Containing Every Vowel and K Consonants II - Medium - Hash TableYou are given a string word and a non-negative integer k. Return the total number of substrings of word that contain every vowel ('a', 'e', 'i', 'o', ... Topics: Hash Table, String, Sliding Window
- 3857. Find Maximum Number of Non Intersecting Substrings - Medium - Hash TableYou are given a string word. Return the maximum number of non-intersecting substrings of word that are at least four characters long and start and end... Topics: Hash Table, String, Dynamic Programming, Greedy
- 1746. Largest Substring Between Two Equal Characters - Easy - Hash TableGiven a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring... Topics: Hash Table, String
- 778. Reorganize String - Medium - Hash TableGiven a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return... Topics: Hash Table, String, Greedy, Sorting, Heap (Priority Queue), Counting
- 2838. Sum of Matrix After Queries - Medium - Hash TableYou are given an integer n and a 0-indexed 2D array queries where queries[i] = [typei, indexi, vali]. Initially, there is a 0-indexed n x n matrix fil... Topics: Array, Hash Table
- 3815. Sum of Largest Prime Substrings - Medium - Hash TableGiven a string s, find the sum of the 3 largest unique prime numbers that can be formed using any of its substrings. Return the sum of the three large... Topics: Hash Table, Math, String, Sorting, Number Theory
- 3700. Subsequences with a Unique Middle Mode I - Hard - Hash TableGiven an integer array nums, find the number of subsequences of size 5 of nums with a unique middle mode. Since the answer may be very large, return i... Topics: Array, Hash Table, Math, Combinatorics
- 1330. Longest Arithmetic Subsequence of Given Difference - Medium - Hash TableGiven an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that th... Topics: Array, Hash Table, Dynamic Programming
- 1267. Remove Zero Sum Consecutive Nodes from Linked List - Medium - Hash TableGiven the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, ... Topics: Hash Table, Linked List
- 2308. Divide Array Into Equal Pairs - Easy - Hash TableYou are given an integer array nums consisting of 2 * n integers. You need to divide nums into n pairs such that: Each element belongs to exactly one ... Topics: Array, Hash Table, Bit Manipulation, Counting
- 2668. Form Smallest Number From Two Digit Arrays - Easy - Hash TableGiven two arrays of unique digits nums1 and nums2, return the smallest number that contains at least one digit from each array.... Topics: Array, Hash Table, Enumeration
- 1468. Check If N and Its Double Exist - Easy - Hash TableGiven an array arr of integers, check if there exist two indices i and j such that : i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j]... Topics: Array, Hash Table, Two Pointers, Binary Search, Sorting
- 1647. Can Convert String in K Moves - Medium - Hash TableGiven two strings s and t, your goal is to convert s into t in k moves or less. During the ith (1 <= i <= k) move you can: Choose any index j (1-index... Topics: Hash Table, String
- 1933. Number of Different Integers in a String - Easy - Hash TableYou are given a string word that consists of digits and lowercase English letters. You will replace every non-digit character with a space. For exampl... Topics: Hash Table, String
- 3610. Find X-Sum of All K-Long Subarrays I - Easy - Hash TableYou are given an array nums of n integers and two integers k and x. The x-sum of an array is calculated by the following procedure: Count the occurren... Topics: Array, Hash Table, Sliding Window, Heap (Priority Queue)
- 3519. Find the Number of Winning Players - Easy - Hash TableYou are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [xi, yi] represents that the player xi pic... Topics: Array, Hash Table, Counting
- 1464. Reduce Array Size to The Half - Medium - Hash TableYou are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum... Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue)
- 1087. Longest Arithmetic Subsequence - Medium - Hash TableGiven an array nums of integers, return the length of the longest arithmetic subsequence in nums. Note that: A subsequence is an array that can be der... Topics: Array, Hash Table, Binary Search, Dynamic Programming
- 808. Number of Matching Subsequences - Medium - Hash TableGiven a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string ge... Topics: Array, Hash Table, String, Binary Search, Dynamic Programming, Trie, Sorting
- 1470. Tweet Counts Per Frequency - Medium - Hash TableA social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These perio... Topics: Hash Table, Binary Search, Design, Sorting, Ordered Set
- 2129. Number of Pairs of Interchangeable Rectangles - Medium - Hash TableYou are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and heigh... Topics: Array, Hash Table, Math, Counting, Number Theory
- 3202. High-Access Employees - Medium - Hash TableYou are given a 2D 0-indexed array of strings, access_times, with size n. For each i where 0 <= i <= n - 1, access_times[i][0] represents the name of ... Topics: Array, Hash Table, String, Sorting
- 1264. Maximum Number of Words You Can Type - Easy - Hash TableThere is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly. Given a string text of words sepa... Topics: Hash Table, String
- 2338. Minimum Consecutive Cards to Pick Up - Medium - Hash TableYou are given an integer array cards where cards[i] represents the value of the ith card. A pair of cards are matching if the cards have the same valu... Topics: Array, Hash Table, Sliding Window
- 1354. Find Players With Zero or One Losses - Medium - Hash TableYou are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match. Retur... Topics: Array, Hash Table, Sorting, Counting
- 3732. Calculate Score After Performing Instructions - Medium - Hash TableYou are given two arrays, instructions and values, both of size n. You need to simulate a process based on the following rules: You start at the first... Topics: Array, Hash Table, String, Simulation
- 2505. Number of Good Paths - Hard - Hash TableThere is a tree (i.e. a connected, undirected graph with no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. You are gi... Topics: Array, Hash Table, Tree, Union Find, Graph, Sorting
- 926. Find and Replace Pattern - Medium - Hash TableGiven a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order. A word match... Topics: Array, Hash Table, String
- 1003. Minimum Area Rectangle II - Medium - Hash TableYou are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of any rectangle formed from these points... Topics: Array, Hash Table, Math, Geometry
- 1261. Swap For Longest Repeated Character Substring - Medium - Hash TableYou are given a string text. You can swap two of the characters in the text. Return the length of the longest substring with repeated characters.... Topics: Hash Table, String, Sliding Window
- 677. Map Sum Pairs - Medium - Hash TableDesign a map that allows you to do the following: Maps a string key to a given value. Returns the sum of the values that have a key with a prefix equa... Topics: Hash Table, String, Design, Trie
- 1422. Divide Array in Sets of K Consecutive Numbers - Medium - Hash TableGiven an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers. Return... Topics: Array, Hash Table, Greedy, Sorting
- 2594. Count Pairs Of Similar Strings - Easy - Hash TableYou are given a 0-indexed string array words. Two strings are similar if they consist of the same characters. For example, "abca" and "cba" are simila... Topics: Array, Hash Table, String, Bit Manipulation, Counting
- 2270. Find All Lonely Numbers in the Array - Medium - Hash TableYou are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the arra... Topics: Array, Hash Table, Counting
- 2581. Divide Players Into Teams of Equal Skill - Medium - Hash TableYou are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player. Divide the players into n / 2 teams ... Topics: Array, Hash Table, Two Pointers, Sorting
- 3408. Count the Number of Special Characters I - Easy - Hash TableYou are given a string word. A letter is called special if it appears both in lowercase and uppercase in word. Return the number of special letters in... Topics: Hash Table, String
- 2059. Unique Length-3 Palindromic Subsequences - Medium - Hash TableGiven a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to ob... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 2487. Optimal Partition of String - Medium - Hash TableGiven a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears i... Topics: Hash Table, String, Greedy
- 2689. Rearranging Fruits - Hard - Hash TableYou have two fruit baskets containing n fruits each. You are given two 0-indexed integer arrays basket1 and basket2 representing the cost of fruit in ... Topics: Array, Hash Table, Greedy, Sort
- 1294. Range Frequency Queries - Medium - Hash TableDesign a data structure to find the frequency of a given value in a given subarray. The frequency of a value in a subarray is the number of occurrence... Topics: Array, Hash Table, Binary Search, Design, Segment Tree
- 1500. Count Largest Group - Easy - Hash TableYou are given an integer n. We need to group the numbers from 1 to n according to the sum of its digits. For example, the numbers 14 and 5 belong to t... Topics: Hash Table, Math
- 3276. Minimum Number of Pushes to Type Word II - Medium - Hash TableYou are given a string word containing lowercase English letters. Telephone keypads have keys mapped with distinct collections of lowercase English le... Topics: Hash Table, String, Greedy, Sorting, Counting
- 2053. Check if All Characters Have Equal Number of Occurrences - Easy - Hash TableGiven a string s, return true if s is a good string, or false otherwise. A string s is good if all the characters that appear in s have the same numbe... Topics: Hash Table, String, Counting
- 2274. Keep Multiplying Found Values by Two - Easy - Hash TableYou are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums. You t... Topics: Array, Hash Table, Sorting, Simulation
- 2377. Check if Number Has Equal Digit Count and Digit Value - Easy - Hash TableYou are given a 0-indexed string num of length n consisting of digits. Return true if for every index i in the range 0 <= i < n, the digit i occurs nu... Topics: Hash Table, String, Counting
- 2696. The Number of Beautiful Subsets - Medium - Hash TableYou are given an array nums of positive integers and a positive integer k. A subset of nums is beautiful if it does not contain two integers with an a... Topics: Array, Hash Table, Math, Dynamic Programming, Backtracking, Sorting, Combinatorics
- 2652. Count Number of Possible Root Nodes - Hard - Hash TableAlice has an undirected tree with n nodes labeled from 0 to n - 1. The tree is represented as a 2D integer array edges of length n - 1 where edges[i] ... Topics: Array, Hash Table, Dynamic Programming, Tree, Depth-First Search
- 3955. Threshold Majority Queries - Hard - Hash TableYou are given an integer array nums of length n and an array queries, where queries[i] = [li, ri, thresholdi]. Return an array of integers ans where a... Topics: Array, Hash Table, Binary Search, Divide and Conquer, Counting, Prefix Sum
- 3570. Count of Substrings Containing Every Vowel and K Consonants I - Medium - Hash TableYou are given a string word and a non-negative integer k. Return the total number of substrings of word that contain every vowel ('a', 'e', 'i', 'o', ... Topics: Hash Table, String, Sliding Window
- 2427. First Letter to Appear Twice - Easy - Hash TableGiven a string s consisting of lowercase English letters, return the first letter to appear twice. Note: A letter a appears twice before another lette... Topics: Hash Table, String, Bit Manipulation, Counting
- 959. 3Sum With Multiplicity - Medium - Hash TableGiven an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target. As ... Topics: Array, Hash Table, Two Pointers, Sorting, Counting
- 599. Minimum Index Sum of Two Lists - Easy - Hash TableGiven two arrays of strings list1 and list2, find the common strings with the least index sum. A common string is a string that appeared in both list1... Topics: Array, Hash Table, String
- 3223. Count Complete Substrings - Hard - Hash TableYou are given a string word and an integer k. A substring s of word is complete if: Each character in s occurs exactly k times. The difference between... Topics: Hash Table, String, Sliding Window
- 2620. Find Consecutive Integers from a Data Stream - Medium - Hash TableFor a stream of integers, implement a data structure that checks if the last k integers parsed in the stream are equal to value. Implement the DataStr... Topics: Hash Table, Design, Queue, Counting, Data Stream
- 2055. Describe the Painting - Medium - Hash TableThere is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each seg... Topics: Array, Hash Table, Sorting, Prefix Sum
- 1649. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target - Medium - Hash TableGiven an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarr... Topics: Array, Hash Table, Greedy, Prefix Sum
- 1423. Maximum Number of Occurrences of a Substring - Medium - Hash TableGiven a string s, return the maximum number of occurrences of any substring under the following rules: The number of unique characters in the substrin... Topics: Hash Table, String, Sliding Window
- 2388. Replace Elements in an Array - Medium - Hash TableYou are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the ith operation you r... Topics: Array, Hash Table, Simulation
- 2163. Kth Distinct String in an Array - Easy - Hash TableA distinct string is a string that is present only once in an array. Given an array of strings arr, and an integer k, return the kth distinct string p... Topics: Array, Hash Table, String, Counting
- 1487. Cinema Seat Allocation - Medium - Hash TableA cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above. Given the ... Topics: Array, Hash Table, Greedy, Bit Manipulation
- 2285. Design Bitset - Medium - Hash TableA Bitset is a data structure that compactly stores bits. Implement the Bitset class: Bitset(int size) Initializes the Bitset with size bits, all of wh... Topics: Array, Hash Table, String, Design
- 839. Short Encoding of Words - Medium - Hash TableA valid encoding of an array of words is any reference string s and array of indices indices such that: words.length == indices.length The reference s... Topics: Array, Hash Table, String, Trie
- 843. Binary Trees With Factors - Medium - Hash TableGiven an array of unique integers, arr, where each integer arr[i] is strictly greater than 1. We make a binary tree using these integers, and each num... Topics: Array, Hash Table, Dynamic Programming, Sorting
- 2525. Count Number of Distinct Integers After Reverse Operations - Medium - Hash TableYou are given an array nums consisting of positive integers. You have to take each integer in the array, reverse its digits, and add it to the end of ... Topics: Array, Hash Table, Math, Counting
- 1632. Number of Good Ways to Split a String - Medium - Hash TableYou are given a string s. A split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to ... Topics: Hash Table, String, Dynamic Programming, Bit Manipulation
- 2005. Check if All the Integers in a Range Are Covered - Easy - Hash TableYou are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between star... Topics: Array, Hash Table, Prefix Sum
- 652. Find Duplicate Subtrees - Medium - Hash TableGiven the root of a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one ... Topics: Hash Table, Tree, Depth-First Search, Binary Tree
- 1770. Minimum Deletions to Make Character Frequencies Unique - Medium - Hash TableA string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of c... Topics: Hash Table, String, Greedy, Sorting
- 2333. Count Number of Rectangles Containing Each Point - Medium - Hash TableYou are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi. You are... Topics: Array, Hash Table, Binary Search, Binary Indexed Tree, Sorting
- 500. Keyboard Row - Easy - Hash TableGiven an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image ... Topics: Array, Hash Table, String
- 1709. Alert Using Same Key-Card Three or More Times in a One Hour Period - Medium - Hash TableLeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and... Topics: Array, Hash Table, String, Sorting
- 2587. Design Memory Allocator - Medium - Hash TableYou are given an integer n representing the size of a 0-indexed memory array. All memory units are initially free. You have a memory allocator with th... Topics: Array, Hash Table, Design, Simulation
- 950. X of a Kind in a Deck of Cards - Easy - Hash TableYou are given an integer array deck where deck[i] represents the number written on the ith card. Partition the cards into one or more groups such that... Topics: Array, Hash Table, Math, Counting, Number Theory
- 1844. Maximum Number of Balls in a Box - Easy - Hash TableYou are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and a... Topics: Hash Table, Math, Counting
- 1256. Rank Transform of an Array - Easy - Hash TableGiven an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: Ra... Topics: Array, Hash Table, Sorting
- 2634. Minimum Common Value - Easy - Hash TableGiven two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays. If there is no common inte... Topics: Array, Hash Table, Two Pointers, Binary Search
- 3629. Total Characters in String After Transformations I - Medium - Hash TableYou are given a string s and an integer t, representing the number of transformations to perform. In one transformation, every character in s is repla... Topics: Hash Table, Math, String, Dynamic Programming, Counting
- 1510. Find Lucky Integer in an Array - Easy - Hash TableGiven an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value. Return the largest lucky integer i... Topics: Array, Hash Table, Counting
- 2824. Check if The Number is Fascinating - Easy - Hash TableYou are given an integer n that consists of exactly 3 digits. We call the number n fascinating if, after the following modification, the resulting num... Topics: Hash Table, Math
- 2240. Intervals Between Identical Elements - Medium - Hash TableYou are given a 0-indexed array of n integers arr. The interval between two elements in arr is defined as the absolute difference between their indice... Topics: Array, Hash Table, Prefix Sum
- 2107. Find Unique Binary String - Medium - Hash TableGiven an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. I... Topics: Array, Hash Table, String, Backtracking
- 889. Buddy Strings - Easy - Hash TableGiven two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false. Swapping letters i... Topics: Hash Table, String
- 1483. Rank Teams by Votes - Medium - Hash TableIn a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition. The ordering of teams is de... Topics: Array, Hash Table, String, Sorting, Counting
- 1612. Avoid Flood in The City - Medium - Hash TableYour country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of wa... Topics: Array, Hash Table, Binary Search, Greedy, Heap (Priority Queue)
- 1217. Relative Sort Array - Easy - Hash TableGiven two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the ... Topics: Array, Hash Table, Sorting, Counting Sort
- 1409. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix - Hard - Hash TableGiven a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 t... Topics: Array, Hash Table, Bit Manipulation, Breadth-First Search, Matrix
- 2524. Largest Positive Integer That Exists With Its Negative - Easy - Hash TableGiven an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array. Return the pos... Topics: Array, Hash Table, Two Pointers, Sorting
- 3420. Find Occurrences of an Element in an Array - Medium - Hash TableYou are given an integer array nums, an integer array queries, and an integer x. For each queries[i], you need to find the index of the queries[i]th o... Topics: Array, Hash Table
- 2724. Convert an Array Into a 2D Array With Conditions - Medium - Hash TableYou are given an integer array nums. You need to create a 2D array from nums satisfying the following conditions: The 2D array should contain only the... Topics: Array, Hash Table
- 2104. Operations on Tree - Medium - Hash TableYou are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of the ith node. The roo... Topics: Array, Hash Table, Tree, Depth-First Search, Breadth-First Search, Design
- 855. Count Unique Characters of All Substrings of a Given String - Hard - Hash TableLet's define a function countUniqueChars(s) that returns the number of unique characters in s. For example, calling countUniqueChars(s) if s = "LEETCO... Topics: Hash Table, String, Dynamic Programming
- 1407. Group the People Given the Group Size They Belong To - Medium - Hash TableThere are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1. You are given an intege... Topics: Array, Hash Table, Greedy
- 3487. Find Maximum Removals From Source String - Medium - Hash TableYou are given a string source of size n, a string pattern that is a subsequence of source, and a sorted integer array targetIndices that contains dist... Topics: Array, Hash Table, Two Pointers, String, Dynamic Programming
- 2661. Smallest Missing Non-negative Integer After Operations - Medium - Hash TableYou are given a 0-indexed integer array nums and an integer value. In one operation, you can add or subtract value from any element of nums. For examp... Topics: Array, Hash Table, Math, Greedy
- 2190. Count Common Words With One Occurrence - Easy - Hash TableGiven two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.... Topics: Array, Hash Table, String, Counting
- 2543. Most Popular Video Creator - Medium - Hash TableYou are given two string arrays creators and ids, and an integer array views, all of length n. The ith video on a platform was created by creators[i],... Topics: Array, Hash Table, String, Sorting, Heap (Priority Queue)
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems