LeetCodechevron_rightarray hash scan

array hash scan Pattern

418 problems

Pattern pages help build reusable solving frames. Identify signals first, then explain state, transition, and edge handling.

Recognition Signals

  • Do you recognize how duplicate checks in rows, columns, and sub-boxes can be optimized using hash sets?
  • Can you map each board cell to its 3x3 sub-box index without extra loops?
  • Do you understand how backtracking helps with solving constraint satisfaction problems like Sudoku?

Solve Flow

  1. 1. Define the active state/window.
  2. 2. Update state while preserving invariants.
  3. 3. Validate with edge-heavy examples.

Common Misses

  • Confusing the 3x3 sub-box indexing, which can lead to missed duplicates or false positives.
  • Not properly updating hash sets after placing numbers, which could lead to incorrect checks for subsequent placements.
  • Swapping incorrectly can lead to infinite loops or missed numbers.

Recommended Ladder

#TitleDifficulty
36

Valid Sudoku

Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …

Medium
37

Sudoku Solver

Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.

Hard
41

First Missing Positive

Identify the smallest missing positive integer in an unsorted array using constant space and linear time scanning techni…

Hard
49

Group Anagrams

Group the anagrams in a list of strings using efficient hash table-based methods, focusing on array scanning.

Medium
73

Set Matrix Zeroes

Modify the matrix in place by setting rows and columns to zero when an element is zero.

Medium
105

Construct Binary Tree from Preorder and Inorder Traversal

Construct a binary tree using preorder and inorder traversal arrays, leveraging array scanning and hash table lookups.

Medium
106

Construct Binary Tree from Inorder and Postorder Traversal

Reconstruct a binary tree from given inorder and postorder arrays using array scanning and hash lookup to optimize recur…

Medium
128

Longest Consecutive Sequence

Find the length of the longest consecutive elements sequence in an unsorted array using array scanning and hash lookup.

Medium
139

Word Break

Determine if a string can be fully segmented into dictionary words using array scanning and hash-based lookups for effic…

Medium
140

Word Break II

Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.

Hard
149

Max Points on a Line

Find the maximum number of points on a straight line in a 2D plane using array scanning and hash lookup.

Hard
169

Majority Element

Find the majority element in an array, where the element appears more than n/2 times, using efficient algorithms.

Easy
217

Contains Duplicate

Determine if an integer array contains any duplicate values by efficiently scanning with a hash lookup to ensure fast de…

Easy
219

Contains Duplicate II

Check if any two equal numbers exist within k indices using array scanning and hash table lookup efficiently.

Easy
229

Majority Element II

Identify all elements in an integer array appearing more than ⌊ n/3 ⌋ times using efficient array scanning and hash coun…

Medium
268

Missing Number

Find the missing number in an array containing distinct numbers in the range [0, n].

Easy
336

Palindrome Pairs

Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.

Hard
347

Top K Frequent Elements

Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.

Medium
349

Intersection of Two Arrays

Find the intersection of two arrays while ensuring unique elements using efficient array scanning and hash lookups.

Easy
350

Intersection of Two Arrays II

Find the intersection of two arrays, accounting for multiple occurrences of the same number.

Easy
380

Insert Delete GetRandom O(1)

Implement a data structure supporting insert, delete, and getRandom in average O(1) using array plus hash mapping.

Medium
381

Insert Delete GetRandom O(1) - Duplicates allowed

This problem challenges you to design a data structure that supports insertion, removal, and random access with O(1) tim…

Hard
391

Perfect Rectangle

Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…

Hard
421

Maximum XOR of Two Numbers in an Array

Find the maximum XOR of two numbers in an integer array using efficient bit manipulation techniques.

Medium
442

Find All Duplicates in an Array

Find all integers that appear twice in an array with O(n) time and constant space complexity.

Medium
447

Number of Boomerangs

Compute all valid boomerang tuples in a point set using array scanning with hash maps to track distances efficiently.

Medium
448

Find All Numbers Disappeared in an Array

Identify all missing numbers in an array using efficient scanning and hash-based lookup for optimal performance.

Easy
454

4Sum II

Count all quadruples from four integer arrays that sum to zero using efficient array scanning and hash table lookups.

Medium
457

Circular Array Loop

Detect whether a circular array contains a loop of consistent direction using efficient array scanning and hash lookup t…

Medium
480

Sliding Window Median

Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…

Hard
491

Non-decreasing Subsequences

Return all possible non-decreasing subsequences with at least two elements from the input array, nums.

Medium
496

Next Greater Element I

Find the next greater element for each number in nums1 from the nums2 array using an optimized approach.

Easy
500

Keyboard Row

Identify all words from a list that can be typed using letters from only one row of a standard American keyboard.

Easy
522

Longest Uncommon Subsequence II

Find the longest string in an array that is not a subsequence of any other string, using array scanning and hash checks …

Medium
523

Continuous Subarray Sum

Identify if any continuous subarray sums to a multiple of k using prefix sums and hash table tracking efficiently.

Medium
525

Contiguous Array

Find the maximum length contiguous subarray with equal numbers of 0s and 1s using array scanning and hash lookup efficie…

Medium
532

K-diff Pairs in an Array

Solve K-diff Pairs in an Array by counting unique differences with a hash map or sorted two-pointer sweep.

Medium
554

Brick Wall

Solve the Brick Wall problem using array scanning and hash lookups to minimize crossed bricks from a vertical line.

Medium
560

Subarray Sum Equals K

Count the total number of contiguous subarrays in an integer array that sum exactly to a target value k using optimized …

Medium
575

Distribute Candies

Maximize the number of different candies Alice can eat given a set of candies and constraints on quantity.

Easy
594

Longest Harmonious Subsequence

Find the length of the longest harmonious subsequence in an integer array using array scanning and hash-based frequency …

Easy
599

Minimum Index Sum of Two Lists

Find the common strings between two lists with the smallest index sum in this easy problem involving array scanning and …

Easy
609

Find Duplicate File in System

Find and return duplicate files in the file system, grouping them by their paths and contents using an array scanning ap…

Medium
621

Task Scheduler

Task Scheduler is solved by counting task frequencies and computing how cooldown gaps force idle slots around the most f…

Medium
632

Smallest Range Covering Elements from K Lists

Find the minimal range covering at least one number from each of k sorted lists using array scanning and hash lookup eff…

Hard
645

Set Mismatch

Identify the duplicated and missing numbers in an integer array using array scanning combined with hash table lookup eff…

Easy
648

Replace Words

Replace words in a sentence using the shortest root from a dictionary, applying efficient array scanning and hash lookup…

Medium
659

Split Array into Consecutive Subsequences

Verify if it's possible to split a sorted array into consecutive subsequences of length 3 or more.

Medium
690

Employee Importance

Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…

Medium
691

Stickers to Spell Word

Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…

Hard
692

Top K Frequent Words

Solve Top K Frequent Words by counting each word, then ordering ties alphabetically so frequency wins before lexicograph…

Medium
697

Degree of an Array

Find the shortest subarray with the same degree as the given array using efficient array scanning and hash lookups.

Easy
705

Design HashSet

Implement a custom HashSet without built-in libraries using array scanning and hash lookup for efficient membership chec…

Easy
706

Design HashMap

Implement a custom HashMap from scratch using array scanning and hash lookup without built-in libraries for efficient ke…

Easy
710

Random Pick with Blacklist

Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…

Hard
720

Longest Word in Dictionary

Find the longest word in a dictionary that can be built one character at a time from other words in the dictionary.

Medium
721

Accounts Merge

Merge accounts by connecting emails and returning each user's sorted email list using array scanning and hash lookup eff…

Medium
740

Delete and Earn

Maximize points by deleting numbers from an array while removing all adjacent values, using dynamic programming efficien…

Medium
745

Prefix and Suffix Search

Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.

Hard
748

Shortest Completing Word

Find the shortest word that completes the license plate by matching all required letters, considering frequency and case…

Easy
752

Open the Lock

Solve the Open the Lock problem using array scanning plus hash lookup to efficiently find the shortest unlock sequence.

Medium
781

Rabbits in Forest

Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.

Medium
792

Number of Matching Subsequences

Given a string s and a list of words, count how many words are subsequences of s using efficient array scanning and hash…

Medium
804

Unique Morse Code Words

Determine how many unique Morse code transformations can be generated from a list of words using a hash table and array …

Easy
811

Subdomain Visit Count

The Subdomain Visit Count problem requires counting the visits to all subdomains of a given domain from a list of count-…

Medium
815

Bus Routes

Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.

Hard
817

Linked List Components

Count the number of connected components in a linked list subset using array scanning and hash table lookups efficiently…

Medium
819

Most Common Word

Find the most frequent non-banned word in a paragraph, excluding punctuation, using an efficient array scan and hash tab…

Easy
820

Short Encoding of Words

Find the minimum length of a reference string encoding an array of words using array scanning and hash lookup efficientl…

Medium
822

Card Flipping Game

The Card Flipping Game problem asks for the smallest integer that can be facing down but not up after flipping cards.

Medium
823

Binary Trees With Factors

Given an array of integers, find how many binary trees can be formed such that non-leaf nodes' values are the product of…

Medium
833

Find And Replace in String

This problem challenges you to perform multiple string replacements at specific indices using a pattern involving array …

Medium
839

Similar String Groups

Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…

Hard
840

Magic Squares In Grid

Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.

Medium
846

Hand of Straights

Check if a hand of cards can be rearranged into groups of consecutive values.

Medium
873

Length of Longest Fibonacci Subsequence

Find the length of the longest Fibonacci-like subsequence from a strictly increasing array of integers.

Medium
874

Walking Robot Simulation

The Walking Robot Simulation problem involves moving a robot in an infinite grid and calculating its furthest distance f…

Medium
888

Fair Candy Swap

Determine which single candy box Alice and Bob should swap to equalize their total candies using array scanning and hash…

Easy
889

Construct Binary Tree from Preorder and Postorder Traversal

Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.

Medium
890

Find and Replace Pattern

Identify all words matching a given pattern by checking consistent letter mappings using hash tables and array scanning …

Medium
893

Groups of Special-Equivalent Strings

Determine the number of special-equivalent string groups using character swaps at even or odd indices efficiently.

Medium
904

Fruit Into Baskets

The Fruit Into Baskets problem requires finding the maximum number of fruits you can pick from a row of trees under spec…

Medium
911

Online Election

Solve the Online Election problem by implementing a class that tracks votes and queries the leading candidate at any giv…

Medium
914

X of a Kind in a Deck of Cards

Solve the problem of determining if a deck can be partitioned into groups with equal occurrences of card values.

Easy
916

Word Subsets

Word Subsets is solved by merging words2 into one max-frequency requirement, then scanning words1 against that fixed let…

Medium
923

3Sum With Multiplicity

Count all unique triplets in an integer array whose sum equals the target, handling multiplicity efficiently using hashi…

Medium
924

Minimize Malware Spread

Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.

Hard
928

Minimize Malware Spread II

Minimize Malware Spread II asks to minimize the spread of malware in a network of nodes by removing one infected node.

Hard
929

Unique Email Addresses

Identify the count of unique email addresses by normalizing local names and using hash-based lookups efficiently.

Easy
930

Binary Subarrays With Sum

Count all contiguous subarrays in a binary array whose elements sum exactly to a given goal using prefix sums efficientl…

Medium
939

Minimum Area Rectangle

Find the minimum area of a rectangle formed by given points on a 2D plane with sides parallel to axes.

Medium
952

Largest Component Size by Common Factor

Find the largest connected component in an array where edges exist between numbers sharing a common factor greater than …

Hard
953

Verifying an Alien Dictionary

Verify if a sequence of words is sorted according to an alien language's custom alphabet order using array scanning and …

Easy
954

Array of Doubled Pairs

Given an array of even length, check if it can be reordered to satisfy a specific doubling condition.

Medium
957

Prison Cells After N Days

Determine the state of 8 prison cells after N days using array scanning and cycle detection for repeated patterns effici…

Medium
959

Regions Cut By Slashes

Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.

Medium
961

N-Repeated Element in Size 2N Array

Find the element that is repeated exactly N times in a 2N-sized array using array scanning and hash lookups.

Easy
963

Minimum Area Rectangle II

Find the minimum area rectangle from given points in the X-Y plane, with sides not necessarily parallel to the axes.

Medium
966

Vowel Spellchecker

Implement a spellchecker that matches queries to a wordlist using exact, case-insensitive, and vowel-error rules efficie…

Medium
974

Subarray Sums Divisible by K

Count the number of subarrays whose sum is divisible by a given integer k using array scanning and hash lookup.

Medium
982

Triples with Bitwise AND Equal To Zero

Count all index triples in an array where the bitwise AND of their elements equals zero using efficient bit manipulation…

Hard
992

Subarrays with K Different Integers

Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.

Hard
996

Number of Squareful Arrays

Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…

Hard
997

Find the Town Judge

Find the Town Judge is an easy LeetCode problem that challenges you to identify a town judge from trust relationships us…

Easy
1001

Grid Illumination

Grid Illumination uses an array scanning approach with hash lookups to check illuminated cells in a large grid based on …

Hard
1002

Find Common Characters

Return an array of common characters from all strings in the given list of words, including duplicates.

Easy
1010

Pairs of Songs With Total Durations Divisible by 60

Calculate the number of song pairs whose total durations sum to a multiple of 60 using array scanning and hash lookups.

Medium
1027

Longest Arithmetic Subsequence

Find the length of the longest arithmetic subsequence in a given integer array using scanning and hash-based lookup.

Medium
1036

Escape a Large Maze

The 'Escape a Large Maze' problem involves navigating a massive grid with blocked squares and finding if a target can be…

Hard
1048

Longest String Chain

Find the longest word chain by scanning arrays and using hash lookups to efficiently track predecessor-successor sequenc…

Medium
1054

Distant Barcodes

Rearrange barcodes in an array so that no two adjacent elements are equal, using a greedy approach and hash table for ef…

Medium
1072

Flip Columns For Maximum Number of Equal Rows

Maximize the number of equal rows in a binary matrix by flipping any number of columns.

Medium
1074

Number of Submatrices That Sum to Target

Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…

Hard
1090

Largest Values From Labels

Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.

Medium
1110

Delete Nodes And Return Forest

Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.

Medium
1122

Relative Sort Array

Sort arr1 by the relative order of arr2, with remaining elements placed in ascending order.

Easy
1124

Longest Well-Performing Interval

The Longest Well-Performing Interval problem challenges you to find the longest subarray where tiring days exceed non-ti…

Medium
1128

Number of Equivalent Domino Pairs

Count all pairs of dominoes that are equivalent by scanning the array and using a hash table for fast lookup.

Easy
1146

Snapshot Array

Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…

Medium
1160

Find Words That Can Be Formed by Characters

Compute the total length of words that can be fully constructed from given characters using array scanning and hash mapp…

Easy
1169

Invalid Transactions

Detect invalid transactions by scanning arrays and cross-checking with hash tables for time, amount, and city conflicts …

Medium
1170

Compare Strings by Frequency of the Smallest Character

Compare Strings by Frequency of the Smallest Character requires counting minimal character frequencies in words and quer…

Medium
1177

Can Make Palindrome from Substring

Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.

Medium
1178

Number of Valid Words for Each Puzzle

Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…

Hard
1202

Smallest String With Swaps

Find the lexicographically smallest string by swapping characters in given pairs of indices.

Medium
1207

Unique Number of Occurrences

Determine if each integer in an array occurs a unique number of times using efficient hash-based counting and verificati…

Easy
1218

Longest Arithmetic Subsequence of Given Difference

Find the longest arithmetic subsequence with a given difference using dynamic programming and hash tables.

Medium
1224

Maximum Equal Frequency

Find the longest prefix of an array where removing one element makes all numbers appear equally, using efficient hash tr…

Hard
1248

Count Number of Nice Subarrays

The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.

Medium
1275

Find Winner on a Tic Tac Toe Game

Determine the winner of a Tic Tac Toe game by scanning moves and using hash lookups for rows, columns, and diagonals eff…

Easy
1282

Group the People Given the Group Size They Belong To

Organize people into groups based on their specified group sizes using array scanning and hash table bucketing efficient…

Medium
1284

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix

Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…

Hard
1296

Divide Array in Sets of K Consecutive Numbers

Determine if an integer array can be partitioned into sets of k consecutive numbers using array scanning and hash mappin…

Medium
1311

Get Watched Videos by Your Friends

Find videos watched by friends up to a given level and return them sorted by frequency and alphabetically.

Medium
1331

Rank Transform of an Array

Transform the elements of an array into their ranks, where the rank represents the size order of the elements.

Easy
1338

Reduce Array Size to The Half

This problem asks to minimize the set of integers removed to reduce an array's size to at least half by removing occurre…

Medium
1345

Jump Game IV

Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…

Hard
1346

Check If N and Its Double Exist

Solve Check If N and Its Double Exist by scanning once and checking doubles or halves in a hash set.

Easy
1357

Apply Discount Every n Orders

Compute customer bills with periodic discounts efficiently using array scanning and hash mapping for fast product price …

Medium
1365

How Many Numbers Are Smaller Than the Current Number

In this problem, you need to determine how many numbers are smaller than each element in an array, focusing on array sca…

Easy
1366

Rank Teams by Votes

Rank Teams by Votes requires counting position-based votes and resolving ties with array scanning and hash lookup techni…

Medium
1386

Cinema Seat Allocation

Determine the maximum number of four-person groups that can be seated in a cinema using array scanning and hash lookup e…

Medium
1394

Find Lucky Integer in an Array

Identify the largest lucky integer in an array by counting frequencies and comparing values with their occurrences effic…

Easy
1418

Display Table of Food Orders in a Restaurant

Generate a restaurant display table from orders by counting each food item per table using array scanning and hash looku…

Medium
1436

Destination City

Find the destination city from a list of paths where each path connects two cities. The city with no outgoing path is th…

Easy
1442

Count Triplets That Can Form Two Arrays of Equal XOR

Efficiently count all triplets in an array where two subarrays formed by splitting have equal XOR using array scanning a…

Medium
1452

People Whose List of Favorite Companies Is Not a Subset of Another List

Identify people whose favorite companies lists are unique and not subsets of any other person's list using efficient arr…

Medium
1460

Make Two Arrays Equal by Reversing Subarrays

Solve Make Two Arrays Equal by Reversing Subarrays by checking whether target and arr contain the same values with match…

Easy
1477

Find Two Non-overlapping Sub-arrays Each With Target Sum

Find two non-overlapping sub-arrays with a given target sum and return the minimal total length efficiently using array …

Medium
1481

Least Number of Unique Integers after K Removals

Find the least number of unique integers after removing exactly k elements from an array using efficient frequency count…

Medium
1487

Making File Names Unique

This problem requires creating unique folder names by appending suffixes to duplicate names using an array scanning and …

Medium
1488

Avoid Flood in The City

This problem asks you to avoid flooding by deciding when to dry lakes between rain events.

Medium
1497

Check If Array Pairs Are Divisible by k

Check if array pairs are divisible by k by pairing elements whose sums are divisible by k using array scanning and hash …

Medium
1512

Number of Good Pairs

Count all index pairs in an array where elements match and the first index is smaller, using hash-based scanning efficie…

Easy
1546

Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

Find the maximum number of non-overlapping subarrays that sum to a given target using efficient scanning and hash lookup…

Medium
1562

Find Latest Group of Size M

Determine the latest step where a contiguous group of ones of exact length m exists using array scanning and hash tracki…

Medium
1577

Number of Ways Where Square of Number Is Equal to Product of Two Numbers

Find the number of triplets where the square of a number equals the product of two others, utilizing array scanning and …

Medium
1590

Make Sum Divisible by P

Determine the minimum-length subarray to remove so the remaining array sum is divisible by a given integer p efficiently…

Medium
1604

Alert Using Same Key-Card Three or More Times in a One Hour Period

Solve LeetCode 1604 by grouping swipe times per employee, sorting each list, and scanning for any three within 60 minute…

Medium
1630

Arithmetic Subarrays

Determine whether subarrays of a given array can be rearranged to form arithmetic sequences using array scanning and has…

Medium
1636

Sort Array by Increasing Frequency

Sort Array by Increasing Frequency requires counting each element and ordering them by frequency, breaking ties with des…

Easy
1640

Check Array Formation Through Concatenation

Determine if an array can be formed by concatenating subarrays without reordering individual elements, using hash lookup…

Easy
1656

Design an Ordered Stream

Design an Ordered Stream that returns values in increasing order based on unique integer IDs with efficient insertion an…

Easy
1658

Minimum Operations to Reduce X to Zero

Find the minimum number of operations to reduce a value x to zero by removing elements from an array.

Medium
1674

Minimum Moves to Make Array Complementary

Find the minimum moves to make an array complementary by analyzing paired sums and using hash lookups for efficiency.

Medium
1679

Max Number of K-Sum Pairs

Max Number of K-Sum Pairs is a problem involving counting disjoint pairs with a given sum k in an array.

Medium
1684

Count the Number of Consistent Strings

Count the number of strings fully composed of allowed characters using array scanning and hash lookup for efficiency.

Easy
1695

Maximum Erasure Value

Maximize the score by erasing a subarray with unique elements in an array of integers.

Medium
1711

Count Good Meals

Count Good Meals asks you to find pairs of food items with a sum of deliciousness equal to a power of two.

Medium
1713

Minimum Operations to Make a Subsequence

Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…

Hard
1726

Tuple with Same Product

Given an array of distinct integers, return the number of tuples where the product of two pairs is the same.

Medium
1733

Minimum Number of People to Teach

Minimize the number of users to teach a language that ensures all friends can communicate in a social network.

Medium
1743

Restore the Array From Adjacent Pairs

Restore the Array From Adjacent Pairs reconstructs a sequence using adjacent element pairs. Efficient hash lookups and a…

Medium
1748

Sum of Unique Elements

Given an array, find the sum of all its unique elements by identifying those that appear only once.

Easy
1775

Equal Sum Arrays With Minimum Number of Operations

Solve the problem of balancing the sums of two integer arrays with minimal operations, using array scanning and hash loo…

Medium
1782

Count Pairs Of Nodes

Given a graph with nodes and edges, count pairs of nodes where the degree sum exceeds a given threshold for each query.

Hard
1807

Evaluate the Bracket Pairs of a String

Quickly evaluate a string with bracketed keys using array scanning and hash table lookups for efficient replacements.

Medium
1814

Count Nice Pairs in an Array

Count Nice Pairs in an Array requires efficiently pairing numbers where nums[i] + rev(nums[j]) equals nums[j] + rev(nums…

Medium
1817

Finding the Users Active Minutes

This problem requires counting unique minutes of user activity on LeetCode based on a series of logs and an integer k.

Medium
1865

Finding Pairs With a Certain Sum

Efficiently track and count pairs across two arrays using array scanning plus hash lookup to support dynamic updates.

Medium
1893

Check if All the Integers in a Range Are Covered

Check if all integers in the range [left, right] are covered by intervals in a given set of ranges.

Easy
1906

Minimum Absolute Difference Queries

Compute minimum absolute differences for subarrays efficiently using array scanning and hash table lookups, leveraging b…

Medium
1912

Design Movie Rental System

Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.

Hard
1938

Maximum Genetic Difference Query

Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.

Hard
1942

The Number of the Smallest Unoccupied Chair

Solve The Number of the Smallest Unoccupied Chair by sorting arrivals and managing freed seats before each new assignmen…

Medium
1943

Describe the Painting

Solve the problem of describing a painted segment with mixed colors using array scanning and hash table lookups.

Medium
1948

Delete Duplicate Folders in System

Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…

Hard
1980

Find Unique Binary String

Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.

Medium
1993

Operations on Tree

Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.

Medium
1994

The Number of Good Subsets

Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.

Hard
1995

Count Special Quadruplets

Count Special Quadruplets requires scanning arrays and using hash lookups to efficiently find quadruplets matching sum c…

Easy
2001

Number of Pairs of Interchangeable Rectangles

Count all pairs of rectangles that share the exact width-to-height ratio using efficient array scanning and hash lookup.

Medium
2006

Count Number of Pairs With Absolute Difference K

Find how many pairs (i, j) with i < j satisfy |nums[i] - nums[j]| == k using array scanning and hash lookup.

Easy
2007

Find Original Array From Doubled Array

Given a shuffled array, determine if it is a doubled array and find the original array.

Medium
2008

Maximum Earnings From Taxi

Maximize earnings by optimizing taxi ride selection and tips using array scanning, hash lookups, and sorting.

Medium
2009

Minimum Number of Operations to Make Array Continuous

Find the minimum number of operations to make an array continuous by modifying elements using array scanning and hash lo…

Hard
2013

Detect Squares

Detect Squares requires tracking points on a 2D plane to quickly count all possible axis-aligned squares using efficient…

Medium
2023

Number of Pairs of Strings With Concatenation Equal to Target

Count all unique index pairs in a string array whose concatenation exactly matches the given target string using efficie…

Medium
2025

Maximum Number of Ways to Partition an Array

Determine the maximum number of ways to split an array into equal sums using at most one element change, leveraging pref…

Hard
2032

Two Out of Three

Identify all elements appearing in at least two of three arrays using efficient scanning and hash lookups for fast verif…

Easy
2043

Simple Bank System

Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…

Medium
2053

Kth Distinct String in an Array

Find the kth distinct string in an array by identifying strings that appear only once, using efficient array scanning an…

Easy
2080

Range Frequency Queries

Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…

Medium
2085

Count Common Words With One Occurrence

Learn how to efficiently count strings appearing exactly once in both arrays using array scanning and hash lookup patter…

Easy
2094

Finding 3-Digit Even Numbers

Generate unique 3-digit even numbers from a given array of digits with duplicates.

Easy
2099

Find Subsequence of Length K With the Largest Sum

Pick the k largest values, then restore their original order to build the maximum-sum subsequence correctly.

Easy
2115

Find All Possible Recipes from Given Supplies

Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …

Medium
2121

Intervals Between Identical Elements

Solve the problem of calculating intervals between identical elements using array scanning and hash lookup.

Medium
2122

Recover the Original Array

Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…

Hard
2131

Longest Palindrome by Concatenating Two Letter Words

Find the maximum-length palindrome by combining two-letter words using array scanning and hash table lookups efficiently…

Medium
2133

Check if Every Row and Column Contains All Numbers

Determine if every row and column in a square matrix contains all numbers from 1 to n without repetition using array sca…

Easy
2135

Count Words Obtained After Adding a Letter

Given startWords and targetWords, check how many targetWords can be formed by adding one letter and rearranging letters …

Medium
2150

Find All Lonely Numbers in the Array

Find lonely numbers in an array where each lonely number appears once and has no adjacent values.

Medium
2154

Keep Multiplying Found Values by Two

The "Keep Multiplying Found Values by Two" problem involves repeatedly multiplying a number by two if it is found in an …

Easy
2166

Design Bitset

Master the Design Bitset problem by efficiently managing bit flips, counts, and indexed updates with array and hash look…

Medium
2170

Minimum Operations to Make the Array Alternating

Given an array, calculate the minimum number of operations needed to make it alternating.

Medium
2190

Most Frequent Number Following Key In an Array

Scan the array once, count which value appears right after the key, and return the uniquely most frequent follower.

Easy
2196

Create Binary Tree From Descriptions

Build a binary tree from descriptions of parent-child relationships using array scanning and hash lookup.

Medium
2201

Count Artifacts That Can Be Extracted

Count the number of artifacts that can be extracted after excavating specified grid cells.

Medium
2206

Divide Array Into Equal Pairs

Determine if an array of 2n integers can be partitioned into n pairs where each pair contains identical elements using h…

Easy
2215

Find the Difference of Two Arrays

Find the Difference of Two Arrays helps you identify unique elements between two integer arrays using array scanning and…

Easy
2225

Find Players With Zero or One Losses

Identify players with zero or one losses by efficiently scanning arrays and counting losses using hash lookups for accur…

Medium
2227

Encrypt and Decrypt Strings

The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …

Hard
2244

Minimum Rounds to Complete All Tasks

The problem requires finding the minimum rounds to complete tasks, focusing on greedy algorithms and hash table lookups.

Medium
2248

Intersection of Multiple Arrays

Find integers that are common across all arrays in a given list of arrays.

Easy
2249

Count Lattice Points Inside a Circle

Count the number of lattice points inside at least one circle in a grid, based on given center and radius data.

Medium
2250

Count Number of Rectangles Containing Each Point

Given a set of rectangles and points, determine how many rectangles contain each point.

Medium
2251

Number of Flowers in Full Bloom

Find the number of flowers in full bloom at the given times for a list of people.

Hard
2260

Minimum Consecutive Cards to Pick Up

Solve Minimum Consecutive Cards to Pick Up by tracking each card's last index and minimizing duplicate spans during one …

Medium
2261

K Divisible Elements Subarrays

Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…

Medium
2273

Find Resultant Array After Removing Anagrams

This problem requires removing adjacent anagrams from a list of words using an array scanning and hash lookup approach.

Easy
2275

Largest Combination With Bitwise AND Greater Than Zero

Find the largest group of integers in an array whose bitwise AND is greater than zero using array scanning and hash look…

Medium
2284

Sender With Largest Word Count

Find the sender with the largest total word count by scanning messages and tallying counts using a hash table efficientl…

Medium
2295

Replace Elements in an Array

Replace Elements in an Array involves applying a series of operations to replace values in an array with new ones based …

Medium
2301

Match Substring After Replacement

Determine if a target substring can appear in a string after optional character replacements using given mappings effici…

Hard
2306

Naming a Company

The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…

Hard
2341

Maximum Number of Pairs in Array

Given an array, count how many pairs can be formed and how many leftovers remain after pairing.

Easy
2342

Max Sum of a Pair With Equal Sum of Digits

Find the maximum sum of two numbers with equal digit sums in a given array of positive integers.

Medium
2347

Best Poker Hand

Determine the strongest poker hand from five cards using array scanning and hash table counting techniques efficiently.

Easy
2350

Shortest Impossible Sequence of Rolls

Find the shortest subsequence that cannot be formed from a sequence of dice rolls, with efficient array scanning and has…

Hard
2352

Equal Row and Column Pairs

Identify all pairs of rows and columns in a square matrix that contain identical elements in the same sequence efficient…

Medium
2353

Design a Food Rating System

Design a food rating system that tracks and updates ratings of foods, finding the highest rated items by cuisine.

Medium
2354

Number of Excellent Pairs

Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…

Hard
2357

Make Array Zero by Subtracting Equal Amounts

Minimize operations to make all array elements zero by subtracting equal amounts in each operation.

Easy
2363

Merge Similar Items

Merge Similar Items combines values and weights from two lists, returning the result sorted by value.

Easy
2364

Count Number of Bad Pairs

Count the number of bad pairs in an array where the difference between indices and values does not match.

Medium
2365

Task Scheduler II

Complete tasks in the optimal number of days by considering breaks and task type constraints.

Medium
2367

Number of Arithmetic Triplets

Count the number of arithmetic triplets in a given strictly increasing array with a specified difference.

Easy
2368

Reachable Nodes With Restrictions

In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…

Medium
2395

Find Subarrays With Equal Sum

Find Subarrays With Equal Sum is solved by scanning adjacent pairs and storing each length-2 sum in a hash set.

Easy
2399

Check Distances Between Same Letters

Verify if each pair of identical letters in a string has the exact number of letters between them as specified in a dist…

Easy
2402

Meeting Rooms III

Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.

Hard
2404

Most Frequent Even Element

Identify the most frequent even element in an array using counting and hash lookup, handling ties by choosing the smalle…

Easy
2418

Sort the People

Sort the People requires pairing names with heights and sorting them in descending height order efficiently using arrays…

Easy
2421

Number of Good Paths

Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.

Hard
2441

Largest Positive Integer That Exists With Its Negative

Find the largest positive integer in an array such that its negative counterpart also exists.

Easy
2442

Count Number of Distinct Integers After Reverse Operations

This problem requires counting distinct integers after performing reverse operations on each integer in an array.

Medium
2451

Odd String Difference

Identify the one string in an array whose consecutive letter differences deviate from all others using array scanning pl…

Easy
2453

Destroy Sequential Targets

Find the minimum seed value to destroy the most targets on a number line, using array scanning and hash lookup.

Medium
2456

Most Popular Video Creator

Identify the most popular video creator by summing views and selecting their top-viewed video with array and hash patter…

Medium
2461

Maximum Sum of Distinct Subarrays With Length K

Find the maximum sum of all distinct-element subarrays of length k using array scanning and hash lookup techniques.

Medium
2465

Number of Distinct Averages

Calculate the number of unique averages formed by repeatedly pairing smallest and largest elements efficiently using has…

Easy
2475

Number of Unequal Triplets in Array

Count all triplets in a positive integer array where each element is distinct using scanning and hash lookup efficiently…

Easy
2488

Count Subarrays With Median K

Count the number of subarrays in a given array with median equal to a specified value k.

Hard
2491

Divide Players Into Teams of Equal Skill

Divide players into equal skill teams and return the sum of their chemistry, or -1 if impossible.

Medium
2499

Minimum Total Cost to Make Arrays Unequal

Calculate the minimum cost to rearrange nums1 so that no element matches nums2 using optimal swaps and hash counting.

Hard
2501

Longest Square Streak in an Array

Find the length of the longest subsequence where each element is a perfect square of its previous one.

Medium
2502

Design Memory Allocator

Design a memory allocator that simulates allocation and deallocation of memory blocks.

Medium
2506

Count Pairs Of Similar Strings

Count similar string pairs by converting each word into a character-set signature and counting matching signatures effic…

Easy
2512

Reward Top K Students

Calculate top K student scores by scanning reports and using hash tables for positive and negative word lookups efficien…

Medium
2521

Distinct Prime Factors of Product of Array

Find the number of distinct prime factors in the product of an array of integers.

Medium
2537

Count the Number of Good Subarrays

Count the number of subarrays that contain at least k pairs of equal elements using array scanning and hash lookup.

Medium
2540

Minimum Common Value

Find the smallest integer appearing in both sorted arrays efficiently using array scanning and hash-based lookup techniq…

Easy
2547

Minimum Cost to Split an Array

Minimize the cost of splitting an array into k subarrays by calculating importance values and applying dynamic programmi…

Hard
2549

Count Distinct Numbers on Board

Compute the number of distinct integers generated on a board using repeated modulo operations over a long sequence of da…

Easy
2554

Maximum Number of Integers to Choose From a Range I

Determine the maximum count of integers from 1 to n avoiding banned numbers while keeping the sum under maxSum.

Medium
2561

Rearranging Fruits

Solve the problem of rearranging fruit baskets by comparing fruit costs and minimizing swaps using array scanning and ha…

Hard
2564

Substring XOR Queries

Solve the Substring XOR Queries problem using array scanning and hash lookup to efficiently handle multiple queries on b…

Medium
2570

Merge Two 2D Arrays by Summing Values

Merge two 2D arrays by summing values with matching ids using array scanning and hash lookup efficiently.

Easy
2581

Count Number of Possible Root Nodes

Given a tree and a set of guesses, find how many nodes can be the root while satisfying the guess constraints.

Hard
2584

Split the Array to Make Coprime Products

Find the smallest index to split an array so that the products of two parts are coprime using array scanning and hash lo…

Hard
2588

Count the Number of Beautiful Subarrays

Count the Number of Beautiful Subarrays is a Medium-level problem involving array scanning and hash table lookup to find…

Medium
2593

Find Score of an Array After Marking All Elements

The problem involves marking elements in an array and calculating the score based on adjacent elements.

Medium
2597

The Number of Beautiful Subsets

Count all non-empty subsets of an array where no two numbers have an absolute difference equal to k, using array scannin…

Medium
2598

Smallest Missing Non-negative Integer After Operations

Find the smallest missing non-negative integer after repeated additions or subtractions of a given value in nums array e…

Medium
2605

Form Smallest Number From Two Digit Arrays

Given two arrays of digits, find the smallest possible number formed by one digit from each array.

Easy
2606

Find the Substring With Maximum Cost

Find the Substring With Maximum Cost requires calculating substring values using a hash lookup for character costs, with…

Medium
2610

Convert an Array Into a 2D Array With Conditions

Learn how to convert an integer array into a 2D array with distinct rows using array scanning plus hash lookup efficient…

Medium
2615

Sum of Distances

In this problem, you calculate an array where each element is the sum of absolute differences of indices for equal value…

Medium
2653

Sliding Subarray Beauty

Compute the xth smallest negative number in each sliding subarray using array scanning and hash frequency tracking effic…

Medium
2657

Find the Prefix Common Array of Two Arrays

This problem challenges you to find the prefix common array of two integer permutations, utilizing array scanning and ha…

Medium
2661

First Completely Painted Row or Column

Find the first index where a row or column is completely painted in a matrix based on an array of integers.

Medium
2670

Find the Distinct Difference Array

Calculate the distinct difference array of a given list of integers by counting distinct elements in the prefix and suff…

Easy
2682

Find the Losers of the Circular Game

Simulate a ball-passing game around a circle using array scanning and hash lookup to find friends who never receive the …

Easy
2707

Extra Characters in a String

The problem asks for the minimum number of extra characters left after optimally breaking a string into substrings found…

Medium
2711

Difference of Number of Distinct Values on Diagonals

Find the difference in the number of distinct diagonal values in a matrix, returning results in a new matrix.

Medium
2713

Maximum Strictly Increasing Cells in a Matrix

Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…

Hard
2718

Sum of Matrix After Queries

Calculate the total sum of a zero-filled n x n matrix after sequentially applying row and column update queries efficien…

Medium
2732

Find a Good Subset of the Matrix

Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…

Hard
2744

Find Maximum Number of String Pairs

Find the maximum number of pairs of distinct strings from an array where one string is the reverse of the other.

Easy
2747

Count Zero Request Servers

Count Zero Request Servers finds the number of servers with zero requests during specific time intervals for a given set…

Medium
2748

Number of Beautiful Pairs

Count all index pairs in an array where the first digit of one number and last digit of another are coprime efficiently.

Easy
2763

Sum of Imbalance Numbers of All Subarrays

Learn how to compute the total imbalance across all subarrays by updating gap counts as each subarray expands.

Hard
2766

Relocate Marbles

Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.

Medium
2768

Number of Black Blocks

Calculate the number of black blocks in a grid given a list of black cell coordinates.

Medium
2780

Minimum Index of a Valid Split

Find the minimum index to split an array such that both subarrays have the same dominant element.

Medium
2781

Length of the Longest Valid Substring

This problem asks for the longest valid substring of a word that doesn't contain any substrings from a forbidden list.

Hard
2784

Check if Array is Good

Determine if a given integer array is a permutation of base[n], containing 1 to n-1 once and n twice, using scanning and…

Easy
2799

Count Complete Subarrays in an Array

Count Complete Subarrays in an Array requires scanning the array while tracking elements to detect subarrays with all di…

Medium
2808

Minimum Seconds to Equalize a Circular Array

Find the minimum number of seconds to equalize a circular array using array scanning and hash lookup techniques.

Medium
2813

Maximum Elegance of a K-Length Subsequence

Maximize elegance of a k-length subsequence from a list of items with profits and categories.

Hard
2815

Max Pair Sum in an Array

Find the maximum sum of two numbers in an array sharing the same largest digit using a hash-based scan efficiently.

Easy
2830

Maximize the Profit as the Salesman

Determine the maximum profit a salesman can earn by strategically selecting non-overlapping offers on consecutive houses…

Medium
2831

Find the Longest Equal Subarray

Find the maximum length of an equal subarray after removing up to k elements using array scanning and hash-based index t…

Medium
2841

Maximum Sum of Almost Unique Subarray

Find the maximum sum of subarrays that contain at least m distinct elements using array scanning and hash lookups effici…

Medium
2845

Count of Interesting Subarrays

Count all subarrays where the number of elements satisfying a modulo condition equals a target k using efficient prefix …

Medium
2848

Points That Intersect With Cars

Count covered integer points by merging overlapping car intervals or marking visited positions on the number line.

Easy
2856

Minimum Array Length After Pair Removals

This problem involves minimizing the length of a sorted array by repeatedly removing adjacent pairs of equal elements.

Medium
2857

Count Pairs of Points With Distance k

Solve the problem of counting pairs of points with distance k using array scanning and hash table techniques.

Medium
2869

Minimum Operations to Collect Elements

Scan from the end, track seen values from 1 to k, and stop once every required number is collected.

Easy
2870

Minimum Number of Operations to Make Array Empty

Minimize the number of operations to make an array empty by leveraging array scanning and hash lookup.

Medium
2875

Minimum Size Subarray in Infinite Array

Find the shortest subarray in an infinite array that sums to a given target using array scanning and hash lookup.

Medium
2897

Apply Operations on Array to Maximize Sum of Squares

Maximizing the sum of squares in an array through bitwise operations on selected elements.

Hard
2902

Count of Sub-Multisets With Bounded Sum

This problem asks you to count the number of sub-multisets within a given array that have a sum in a specified range.

Hard
2910

Minimum Number of Groups to Create a Valid Assignment

The problem involves sorting balls into boxes while minimizing the number of boxes, adhering to size constraints.

Medium
2913

Subarrays Distinct Element Sum of Squares I

Compute the sum of squares of distinct elements for all subarrays using array scanning with hash lookups efficiently.

Easy
2932

Maximum Strong Pair XOR I

Find the maximum XOR of any strong pair in an integer array using array scanning and hash-based lookups efficiently.

Easy
2933

High-Access Employees

Identify employees with high system access within one-hour periods based on access logs.

Medium
2935

Maximum Strong Pair XOR II

Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.

Hard
2956

Find Common Elements Between Two Arrays

Quickly find all numbers that appear in both arrays using scanning and hash lookup to handle duplicates efficiently.

Easy
2958

Length of Longest Subarray With at Most K Frequency

Find the maximum length subarray where each number appears at most k times using array scanning and hash lookups.

Medium
2963

Count the Number of Good Partitions

Calculate how many ways to partition an array into contiguous subarrays where no number repeats across segments using ha…

Hard
2965

Find Missing and Repeated Values

Find the missing and repeated numbers in an n x n grid using array scanning and hash lookup.

Easy
2975

Maximum Square Area by Removing Fences From a Field

This problem challenges you to calculate the largest square area possible by removing fences from a given rectangular fi…

Medium
2996

Smallest Missing Integer Greater Than Sequential Prefix Sum

Find the smallest missing integer greater than the sum of the longest sequential prefix in an array.

Easy
3002

Maximum Size of a Set After Removals

Maximize a set size by strategically removing half of elements from two arrays using hash lookups and array scanning.

Medium
3005

Count Elements With Maximum Frequency

Count Elements With Maximum Frequency is solved by counting each value, tracking the highest count, and summing matching…

Easy
3013

Divide an Array Into Subarrays With Minimum Cost II

This problem asks to divide an array into subarrays with a minimal cost and certain constraints on subarray positions.

Hard
3020

Find the Maximum Number of Elements in Subset

This problem asks you to find the maximum subset size where each number in the subset follows a specific pattern with ha…

Medium
3026

Maximum Good Subarray Sum

Find the maximum sum of any subarray where the first and last elements differ by exactly k using efficient array scannin…

Medium
3035

Maximum Palindromes After Operations

The problem focuses on maximizing the number of palindromes that can be formed from a given list of words through specif…

Medium
3039

Apply Operations to Make String Empty

Learn how to systematically apply operations on a string using array scanning and hash lookups to reduce it efficiently.

Medium
3043

Find the Length of the Longest Common Prefix

Determine the length of the longest common prefix between two integer arrays using array scanning and hash lookup effici…

Medium
3044

Most Frequent Prime

Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…

Medium
3046

Split the Array

Determine if an even-length array can be split into two parts with all distinct elements using hash lookup scanning.

Easy
3071

Minimum Operations to Write the Letter Y on a Grid

Find the minimum number of operations to write the letter Y on a grid by altering cell values.

Medium
3076

Shortest Uncommon Substring in an Array

Find the shortest substring for each string in an array that does not appear in any other string efficiently using hashi…

Medium
3080

Mark Elements on Array by Performing Queries

Efficiently mark elements in an array based on queries using scanning plus hash lookup to track marked indices and compu…

Medium
3092

Most Frequent IDs

Track the most frequent ID after each update in a dynamic collection of IDs with changing frequencies.

Medium
3128

Right Triangles

Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.

Medium
3134

Find the Median of the Uniqueness Array

Given a nums array, find the median of its uniqueness array by considering all subarrays and their distinct element coun…

Hard
3143

Maximum Points Inside the Square

Find the maximum number of points inside a valid square centered at the origin using a scanning and hashing approach.

Medium
3153

Sum of Digit Differences of All Pairs

Sum of Digit Differences of All Pairs is a problem that involves counting digit differences in pairs from an array of in…

Medium
3158

Find the XOR of Numbers Which Appear Twice

Find the XOR of numbers appearing twice by scanning the array and using a hash table for efficient tracking and combinat…

Easy
3159

Find Occurrences of an Element in an Array

Determine the position of each requested occurrence of x in nums using a hash table and efficient array scanning.

Medium
3160

Find the Number of Distinct Colors Among the Balls

Efficiently track colors on balls using array scanning and hash lookup to return the count of distinct colors after each…

Medium
3162

Find the Number of Good Pairs I

Count all good pairs where an element in nums1 is divisible by a scaled element in nums2 using efficient array scanning.

Easy
3164

Find the Number of Good Pairs II

Calculate total good pairs by scanning two arrays and using hash lookup to match divisible elements efficiently with k.

Medium
3176

Find the Maximum Length of a Good Subsequence I

Find the maximum length of a good subsequence by scanning arrays and using hash lookups for value remapping efficiently.

Medium
3177

Find the Maximum Length of a Good Subsequence II

Determine the maximum length of a good subsequence in an integer array using array scanning and hash lookup efficiently.

Hard
3184

Count Pairs That Form a Complete Day I

Count all pairs in an array where their sum forms a complete day using hash-based counting for efficiency.

Easy
3185

Count Pairs That Form a Complete Day II

Count the number of valid pairs of hours that form a complete day by checking if their sum is a multiple of 24.

Medium
3186

Maximum Total Damage With Spell Casting

Calculate the maximum total damage by selectively casting spells while avoiding adjacent power conflicts using array sca…

Medium
3217

Delete Nodes From Linked List Present in Array

Remove nodes from a linked list if their values exist in a given array.

Medium
3224

Minimum Array Changes to Make Differences Equal

Minimize changes to make array differences equal by replacing elements within a given range.

Medium
3238

Find the Number of Winning Players

Find how many players in a game win by picking more balls of a single color than their index position.

Easy
3242

Design Neighbor Sum Service

Design a service that computes sums for adjacent and diagonal elements in a 2D grid.

Easy
3265

Count Almost Equal Pairs I

Count Almost Equal Pairs I involves finding pairs of elements that can be made equal by swapping at most one digit.

Medium
3267

Count Almost Equal Pairs II

Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.

Hard
3289

The Two Sneaky Numbers of Digitville

Find the two numbers that appear twice in a list of integers from 0 to n-1 using array scanning plus hash lookup efficie…

Easy
3295

Report Spam Message

Determine if a message contains at least two banned words using array scanning and hash lookup.

Medium
3311

Construct 2D Grid Matching Graph Layout

This problem challenges you to construct a 2D grid from an undirected graph using a given set of edges.

Hard
3312

Sorted GCD Pair Queries

Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…

Hard
3316

Find Maximum Removals From Source String

Determine the maximum number of characters you can remove from source while keeping pattern as a subsequence using array…

Medium
3318

Find X-Sum of All K-Long Subarrays I

Compute the x-sum of every subarray of length k efficiently using array scanning combined with hash lookup techniques.

Easy
3321

Find X-Sum of All K-Long Subarrays II

Calculate the x-sum for every k-length subarray using efficient array scanning and hash-based counting techniques.

Hard
3327

Check if DFS Strings Are Palindromes

Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…

Hard
3331

Find Subtree Sizes After Changes

Calculate the sizes of all subtrees after simultaneous parent changes using array scanning and hash-based counting effic…

Medium
3351

Sum of Good Subsequences

Calculate the sum of all good subsequences in an array where consecutive numbers differ by exactly one.

Hard
3371

Identify the Largest Outlier in an Array

Identify the largest outlier in an integer array using scanning and hash lookup for efficient detection and validation.

Medium
3375

Minimum Operations to Make Array Values Equal to K

Find the minimum operations to convert an array to all values equal k using array scanning and hash lookup efficiently.

Easy
3378

Count Connected Components in LCM Graph

Determine the number of connected components in an LCM-based graph using array scanning and hash-based connectivity chec…

Hard
3381

Maximum Subarray Sum With Length Divisible by K

Find the maximum sum of a subarray where the length of the subarray is divisible by k.

Medium
3395

Subsequences with a Unique Middle Mode I

Count subsequences of size 5 with a unique middle mode in an integer array using hash table and combinatorics.

Hard
3396

Minimum Number of Operations to Make Elements in Array Distinct

Find the minimum number of operations to make all elements of an array distinct.

Easy
3404

Count Special Subsequences

Count the number of special subsequences in an array of positive integers, focusing on efficient array scanning and hash…

Medium
3425

Longest Special Path

Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.

Hard
3434

Maximum Frequency After Subarray Operation

Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…

Medium
3447

Assign Elements to Groups with Constraints

Assign elements to groups by size constraints with a sieve-like approach to find suitable element matches efficiently.

Medium
3471

Find the Largest Almost Missing Integer

Find the largest almost missing integer in an array where it appears in exactly one subarray of size k.

Easy
3483

Unique 3-Digit Even Numbers

Given an array of digits, find how many distinct 3-digit even numbers can be formed without repetition of digits and no …

Easy
3484

Design Spreadsheet

Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…

Medium
3486

Longest Special Path II

Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…

Hard
3487

Maximum Unique Subarray Sum After Deletion

Maximize the sum of a subarray after performing deletions, ensuring elements remain unique.

Easy
3488

Closest Equal Element Queries

Find the nearest index with the same value for each query using array scanning combined with hash lookups efficiently.

Medium
3493

Properties Graph

Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…

Medium
3505

Minimum Operations to Make Elements Within K Subarrays Equal

Compute the minimum operations to ensure at least k non-overlapping subarrays of size x have all equal elements efficien…

Hard
3507

Minimum Pair Removal to Sort Array I

This problem asks for the minimum number of operations to make an array non-decreasing by removing pairs of elements.

Easy
3508

Implement Router

Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.

Medium
3509

Maximum Product of Subsequences With an Alternating Sum Equal to K

Find the maximum product of a subsequence in an array with an alternating sum equal to a given target.

Hard
3510

Minimum Pair Removal to Sort Array II

The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.

Hard
3522

Calculate Score After Performing Instructions

Simulate a series of add and jump instructions on arrays to compute the final score efficiently using array scanning and…

Medium
3527

Find the Most Common Response

Find the most common survey response after eliminating duplicates within each day, using array scanning and hash lookups…

Medium
3531

Count Covered Buildings

Determine how many buildings in an n x n city are completely surrounded using array scanning and hash lookup efficiently…

Medium
3532

Path Existence Queries in a Graph I

Determine if paths exist between nodes using array scanning and hash lookups for efficient component checks in graphs.

Medium
3542

Minimum Operations to Convert All Elements to Zero

Calculate the fewest operations to turn all numbers in an array to zero using subarray minimum elimination strategy.

Medium
3548

Equal Sum Grid Partition II

Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.

Hard
3551

Minimum Swaps to Sort by Digit Sum

Calculate the minimum swaps to sort an array by digit sum, ensuring correct order with tiebreaker values for efficiency.

Medium
3552

Grid Teleportation Traversal

Find the minimum moves to traverse a 2D grid using standard steps and one-time portal teleports efficiently.

Medium
3568

Minimum Moves to Clean the Classroom

Solve the "Minimum Moves to Clean the Classroom" problem using array scanning and hash lookup for an optimized solution.

Medium
3572

Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values

Select three distinct x-values from arrays to maximize the sum of their corresponding y-values efficiently using hashing…

Medium
3583

Count Special Triplets

Count Special Triplets requires scanning an array while tracking counts of previous and next values efficiently with has…

Medium
3588

Find Maximum Area of a Triangle

Find the maximum area of a triangle from 2D coordinates with at least one side parallel to the x-axis or y-axis.

Medium
3591

Check if Any Element Has Prime Frequency

Check if any element in the array has a prime frequency count, leveraging array scanning and hash table lookup.

Easy
3606

Coupon Code Validator

The Coupon Code Validator problem requires filtering and sorting coupons based on specific criteria for validity.

Easy
3607

Power Grid Maintenance

Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…

Medium
3623

Count Number of Trapezoids I

Given a list of distinct points, count the number of unique horizontal trapezoids that can be formed by selecting four p…

Medium
3625

Count Number of Trapezoids II

Count Number of Trapezoids II requires scanning point pairs and hashing slopes to efficiently find parallel sides in arr…

Hard

Related Topics

Array scanning plus hash lookup LeetCode Pattern: 418 Solutions