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. Define the active state/window.
- 2. Update state while preserving invariants.
- 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
Valid Sudoku
Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …
Sudoku Solver
Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.
First Missing Positive
Identify the smallest missing positive integer in an unsorted array using constant space and linear time scanning techni…
Group Anagrams
Group the anagrams in a list of strings using efficient hash table-based methods, focusing on array scanning.
Set Matrix Zeroes
Modify the matrix in place by setting rows and columns to zero when an element is zero.
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.
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…
Longest Consecutive Sequence
Find the length of the longest consecutive elements sequence in an unsorted array using array scanning and hash lookup.
Word Break
Determine if a string can be fully segmented into dictionary words using array scanning and hash-based lookups for effic…
Word Break II
Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.
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.
Majority Element
Find the majority element in an array, where the element appears more than n/2 times, using efficient algorithms.
Contains Duplicate
Determine if an integer array contains any duplicate values by efficiently scanning with a hash lookup to ensure fast de…
Contains Duplicate II
Check if any two equal numbers exist within k indices using array scanning and hash table lookup efficiently.
Majority Element II
Identify all elements in an integer array appearing more than ⌊ n/3 ⌋ times using efficient array scanning and hash coun…
Missing Number
Find the missing number in an array containing distinct numbers in the range [0, n].
Palindrome Pairs
Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.
Top K Frequent Elements
Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.
Intersection of Two Arrays
Find the intersection of two arrays while ensuring unique elements using efficient array scanning and hash lookups.
Intersection of Two Arrays II
Find the intersection of two arrays, accounting for multiple occurrences of the same number.
Insert Delete GetRandom O(1)
Implement a data structure supporting insert, delete, and getRandom in average O(1) using array plus hash mapping.
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…
Perfect Rectangle
Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…
Maximum XOR of Two Numbers in an Array
Find the maximum XOR of two numbers in an integer array using efficient bit manipulation techniques.
Find All Duplicates in an Array
Find all integers that appear twice in an array with O(n) time and constant space complexity.
Number of Boomerangs
Compute all valid boomerang tuples in a point set using array scanning with hash maps to track distances efficiently.
Find All Numbers Disappeared in an Array
Identify all missing numbers in an array using efficient scanning and hash-based lookup for optimal performance.
4Sum II
Count all quadruples from four integer arrays that sum to zero using efficient array scanning and hash table lookups.
Circular Array Loop
Detect whether a circular array contains a loop of consistent direction using efficient array scanning and hash lookup t…
Sliding Window Median
Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…
Non-decreasing Subsequences
Return all possible non-decreasing subsequences with at least two elements from the input array, nums.
Next Greater Element I
Find the next greater element for each number in nums1 from the nums2 array using an optimized approach.
Keyboard Row
Identify all words from a list that can be typed using letters from only one row of a standard American keyboard.
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 …
Continuous Subarray Sum
Identify if any continuous subarray sums to a multiple of k using prefix sums and hash table tracking efficiently.
Contiguous Array
Find the maximum length contiguous subarray with equal numbers of 0s and 1s using array scanning and hash lookup efficie…
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.
Brick Wall
Solve the Brick Wall problem using array scanning and hash lookups to minimize crossed bricks from a vertical line.
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 …
Distribute Candies
Maximize the number of different candies Alice can eat given a set of candies and constraints on quantity.
Longest Harmonious Subsequence
Find the length of the longest harmonious subsequence in an integer array using array scanning and hash-based frequency …
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 …
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…
Task Scheduler
Task Scheduler is solved by counting task frequencies and computing how cooldown gaps force idle slots around the most f…
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…
Set Mismatch
Identify the duplicated and missing numbers in an integer array using array scanning combined with hash table lookup eff…
Replace Words
Replace words in a sentence using the shortest root from a dictionary, applying efficient array scanning and hash lookup…
Split Array into Consecutive Subsequences
Verify if it's possible to split a sorted array into consecutive subsequences of length 3 or more.
Employee Importance
Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…
Stickers to Spell Word
Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…
Top K Frequent Words
Solve Top K Frequent Words by counting each word, then ordering ties alphabetically so frequency wins before lexicograph…
Degree of an Array
Find the shortest subarray with the same degree as the given array using efficient array scanning and hash lookups.
Design HashSet
Implement a custom HashSet without built-in libraries using array scanning and hash lookup for efficient membership chec…
Design HashMap
Implement a custom HashMap from scratch using array scanning and hash lookup without built-in libraries for efficient ke…
Random Pick with Blacklist
Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…
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.
Accounts Merge
Merge accounts by connecting emails and returning each user's sorted email list using array scanning and hash lookup eff…
Delete and Earn
Maximize points by deleting numbers from an array while removing all adjacent values, using dynamic programming efficien…
Prefix and Suffix Search
Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.
Shortest Completing Word
Find the shortest word that completes the license plate by matching all required letters, considering frequency and case…
Open the Lock
Solve the Open the Lock problem using array scanning plus hash lookup to efficiently find the shortest unlock sequence.
Rabbits in Forest
Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.
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…
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 …
Subdomain Visit Count
The Subdomain Visit Count problem requires counting the visits to all subdomains of a given domain from a list of count-…
Bus Routes
Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.
Linked List Components
Count the number of connected components in a linked list subset using array scanning and hash table lookups efficiently…
Most Common Word
Find the most frequent non-banned word in a paragraph, excluding punctuation, using an efficient array scan and hash tab…
Short Encoding of Words
Find the minimum length of a reference string encoding an array of words using array scanning and hash lookup efficientl…
Card Flipping Game
The Card Flipping Game problem asks for the smallest integer that can be facing down but not up after flipping cards.
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…
Find And Replace in String
This problem challenges you to perform multiple string replacements at specific indices using a pattern involving array …
Similar String Groups
Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…
Magic Squares In Grid
Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.
Hand of Straights
Check if a hand of cards can be rearranged into groups of consecutive values.
Length of Longest Fibonacci Subsequence
Find the length of the longest Fibonacci-like subsequence from a strictly increasing array of integers.
Walking Robot Simulation
The Walking Robot Simulation problem involves moving a robot in an infinite grid and calculating its furthest distance f…
Fair Candy Swap
Determine which single candy box Alice and Bob should swap to equalize their total candies using array scanning and hash…
Construct Binary Tree from Preorder and Postorder Traversal
Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.
Find and Replace Pattern
Identify all words matching a given pattern by checking consistent letter mappings using hash tables and array scanning …
Groups of Special-Equivalent Strings
Determine the number of special-equivalent string groups using character swaps at even or odd indices efficiently.
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…
Online Election
Solve the Online Election problem by implementing a class that tracks votes and queries the leading candidate at any giv…
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.
Word Subsets
Word Subsets is solved by merging words2 into one max-frequency requirement, then scanning words1 against that fixed let…
3Sum With Multiplicity
Count all unique triplets in an integer array whose sum equals the target, handling multiplicity efficiently using hashi…
Minimize Malware Spread
Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.
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.
Unique Email Addresses
Identify the count of unique email addresses by normalizing local names and using hash-based lookups efficiently.
Binary Subarrays With Sum
Count all contiguous subarrays in a binary array whose elements sum exactly to a given goal using prefix sums efficientl…
Minimum Area Rectangle
Find the minimum area of a rectangle formed by given points on a 2D plane with sides parallel to axes.
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 …
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 …
Array of Doubled Pairs
Given an array of even length, check if it can be reordered to satisfy a specific doubling condition.
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…
Regions Cut By Slashes
Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.
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.
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.
Vowel Spellchecker
Implement a spellchecker that matches queries to a wordlist using exact, case-insensitive, and vowel-error rules efficie…
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.
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…
Subarrays with K Different Integers
Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.
Number of Squareful Arrays
Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…
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…
Grid Illumination
Grid Illumination uses an array scanning approach with hash lookups to check illuminated cells in a large grid based on …
Find Common Characters
Return an array of common characters from all strings in the given list of words, including duplicates.
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.
Longest Arithmetic Subsequence
Find the length of the longest arithmetic subsequence in a given integer array using scanning and hash-based lookup.
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…
Longest String Chain
Find the longest word chain by scanning arrays and using hash lookups to efficiently track predecessor-successor sequenc…
Distant Barcodes
Rearrange barcodes in an array so that no two adjacent elements are equal, using a greedy approach and hash table for ef…
Flip Columns For Maximum Number of Equal Rows
Maximize the number of equal rows in a binary matrix by flipping any number of columns.
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…
Largest Values From Labels
Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.
Delete Nodes And Return Forest
Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.
Relative Sort Array
Sort arr1 by the relative order of arr2, with remaining elements placed in ascending order.
Longest Well-Performing Interval
The Longest Well-Performing Interval problem challenges you to find the longest subarray where tiring days exceed non-ti…
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.
Snapshot Array
Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…
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…
Invalid Transactions
Detect invalid transactions by scanning arrays and cross-checking with hash tables for time, amount, and city conflicts …
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…
Can Make Palindrome from Substring
Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.
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…
Smallest String With Swaps
Find the lexicographically smallest string by swapping characters in given pairs of indices.
Unique Number of Occurrences
Determine if each integer in an array occurs a unique number of times using efficient hash-based counting and verificati…
Longest Arithmetic Subsequence of Given Difference
Find the longest arithmetic subsequence with a given difference using dynamic programming and hash tables.
Maximum Equal Frequency
Find the longest prefix of an array where removing one element makes all numbers appear equally, using efficient hash tr…
Count Number of Nice Subarrays
The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.
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…
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…
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…
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…
Get Watched Videos by Your Friends
Find videos watched by friends up to a given level and return them sorted by frequency and alphabetically.
Rank Transform of an Array
Transform the elements of an array into their ranks, where the rank represents the size order of the elements.
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…
Jump Game IV
Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…
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.
Apply Discount Every n Orders
Compute customer bills with periodic discounts efficiently using array scanning and hash mapping for fast product price …
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…
Rank Teams by Votes
Rank Teams by Votes requires counting position-based votes and resolving ties with array scanning and hash lookup techni…
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…
Find Lucky Integer in an Array
Identify the largest lucky integer in an array by counting frequencies and comparing values with their occurrences effic…
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…
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…
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…
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…
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…
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 …
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…
Making File Names Unique
This problem requires creating unique folder names by appending suffixes to duplicate names using an array scanning and …
Avoid Flood in The City
This problem asks you to avoid flooding by deciding when to dry lakes between rain events.
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 …
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…
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…
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…
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 …
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…
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…
Arithmetic Subarrays
Determine whether subarrays of a given array can be rearranged to form arithmetic sequences using array scanning and has…
Sort Array by Increasing Frequency
Sort Array by Increasing Frequency requires counting each element and ordering them by frequency, breaking ties with des…
Check Array Formation Through Concatenation
Determine if an array can be formed by concatenating subarrays without reordering individual elements, using hash lookup…
Design an Ordered Stream
Design an Ordered Stream that returns values in increasing order based on unique integer IDs with efficient insertion an…
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.
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.
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.
Count the Number of Consistent Strings
Count the number of strings fully composed of allowed characters using array scanning and hash lookup for efficiency.
Maximum Erasure Value
Maximize the score by erasing a subarray with unique elements in an array of integers.
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.
Minimum Operations to Make a Subsequence
Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…
Tuple with Same Product
Given an array of distinct integers, return the number of tuples where the product of two pairs is the same.
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.
Restore the Array From Adjacent Pairs
Restore the Array From Adjacent Pairs reconstructs a sequence using adjacent element pairs. Efficient hash lookups and a…
Sum of Unique Elements
Given an array, find the sum of all its unique elements by identifying those that appear only once.
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…
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.
Evaluate the Bracket Pairs of a String
Quickly evaluate a string with bracketed keys using array scanning and hash table lookups for efficient replacements.
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…
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.
Finding Pairs With a Certain Sum
Efficiently track and count pairs across two arrays using array scanning plus hash lookup to support dynamic updates.
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.
Minimum Absolute Difference Queries
Compute minimum absolute differences for subarrays efficiently using array scanning and hash table lookups, leveraging b…
Design Movie Rental System
Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.
Maximum Genetic Difference Query
Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.
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…
Describe the Painting
Solve the problem of describing a painted segment with mixed colors using array scanning and hash table lookups.
Delete Duplicate Folders in System
Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…
Find Unique Binary String
Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.
Operations on Tree
Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.
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.
Count Special Quadruplets
Count Special Quadruplets requires scanning arrays and using hash lookups to efficiently find quadruplets matching sum c…
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.
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.
Find Original Array From Doubled Array
Given a shuffled array, determine if it is a doubled array and find the original array.
Maximum Earnings From Taxi
Maximize earnings by optimizing taxi ride selection and tips using array scanning, hash lookups, and sorting.
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…
Detect Squares
Detect Squares requires tracking points on a 2D plane to quickly count all possible axis-aligned squares using efficient…
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…
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…
Two Out of Three
Identify all elements appearing in at least two of three arrays using efficient scanning and hash lookups for fast verif…
Simple Bank System
Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…
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…
Range Frequency Queries
Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…
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…
Finding 3-Digit Even Numbers
Generate unique 3-digit even numbers from a given array of digits with duplicates.
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.
Find All Possible Recipes from Given Supplies
Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …
Intervals Between Identical Elements
Solve the problem of calculating intervals between identical elements using array scanning and hash lookup.
Recover the Original Array
Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…
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…
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…
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 …
Find All Lonely Numbers in the Array
Find lonely numbers in an array where each lonely number appears once and has no adjacent values.
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 …
Design Bitset
Master the Design Bitset problem by efficiently managing bit flips, counts, and indexed updates with array and hash look…
Minimum Operations to Make the Array Alternating
Given an array, calculate the minimum number of operations needed to make it alternating.
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.
Create Binary Tree From Descriptions
Build a binary tree from descriptions of parent-child relationships using array scanning and hash lookup.
Count Artifacts That Can Be Extracted
Count the number of artifacts that can be extracted after excavating specified grid cells.
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…
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…
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…
Encrypt and Decrypt Strings
The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …
Minimum Rounds to Complete All Tasks
The problem requires finding the minimum rounds to complete tasks, focusing on greedy algorithms and hash table lookups.
Intersection of Multiple Arrays
Find integers that are common across all arrays in a given list of arrays.
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.
Count Number of Rectangles Containing Each Point
Given a set of rectangles and points, determine how many rectangles contain each point.
Number of Flowers in Full Bloom
Find the number of flowers in full bloom at the given times for a list of people.
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 …
K Divisible Elements Subarrays
Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…
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.
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…
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…
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 …
Match Substring After Replacement
Determine if a target substring can appear in a string after optional character replacements using given mappings effici…
Naming a Company
The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…
Maximum Number of Pairs in Array
Given an array, count how many pairs can be formed and how many leftovers remain after pairing.
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.
Best Poker Hand
Determine the strongest poker hand from five cards using array scanning and hash table counting techniques efficiently.
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…
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…
Design a Food Rating System
Design a food rating system that tracks and updates ratings of foods, finding the highest rated items by cuisine.
Number of Excellent Pairs
Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…
Make Array Zero by Subtracting Equal Amounts
Minimize operations to make all array elements zero by subtracting equal amounts in each operation.
Merge Similar Items
Merge Similar Items combines values and weights from two lists, returning the result sorted by value.
Count Number of Bad Pairs
Count the number of bad pairs in an array where the difference between indices and values does not match.
Task Scheduler II
Complete tasks in the optimal number of days by considering breaks and task type constraints.
Number of Arithmetic Triplets
Count the number of arithmetic triplets in a given strictly increasing array with a specified difference.
Reachable Nodes With Restrictions
In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…
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.
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…
Meeting Rooms III
Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.
Most Frequent Even Element
Identify the most frequent even element in an array using counting and hash lookup, handling ties by choosing the smalle…
Sort the People
Sort the People requires pairing names with heights and sorting them in descending height order efficiently using arrays…
Number of Good Paths
Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.
Largest Positive Integer That Exists With Its Negative
Find the largest positive integer in an array such that its negative counterpart also exists.
Count Number of Distinct Integers After Reverse Operations
This problem requires counting distinct integers after performing reverse operations on each integer in an array.
Odd String Difference
Identify the one string in an array whose consecutive letter differences deviate from all others using array scanning pl…
Destroy Sequential Targets
Find the minimum seed value to destroy the most targets on a number line, using array scanning and hash lookup.
Most Popular Video Creator
Identify the most popular video creator by summing views and selecting their top-viewed video with array and hash patter…
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.
Number of Distinct Averages
Calculate the number of unique averages formed by repeatedly pairing smallest and largest elements efficiently using has…
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…
Count Subarrays With Median K
Count the number of subarrays in a given array with median equal to a specified value k.
Divide Players Into Teams of Equal Skill
Divide players into equal skill teams and return the sum of their chemistry, or -1 if impossible.
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.
Longest Square Streak in an Array
Find the length of the longest subsequence where each element is a perfect square of its previous one.
Design Memory Allocator
Design a memory allocator that simulates allocation and deallocation of memory blocks.
Count Pairs Of Similar Strings
Count similar string pairs by converting each word into a character-set signature and counting matching signatures effic…
Reward Top K Students
Calculate top K student scores by scanning reports and using hash tables for positive and negative word lookups efficien…
Distinct Prime Factors of Product of Array
Find the number of distinct prime factors in the product of an array of integers.
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.
Minimum Common Value
Find the smallest integer appearing in both sorted arrays efficiently using array scanning and hash-based lookup techniq…
Minimum Cost to Split an Array
Minimize the cost of splitting an array into k subarrays by calculating importance values and applying dynamic programmi…
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…
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.
Rearranging Fruits
Solve the problem of rearranging fruit baskets by comparing fruit costs and minimizing swaps using array scanning and ha…
Substring XOR Queries
Solve the Substring XOR Queries problem using array scanning and hash lookup to efficiently handle multiple queries on b…
Merge Two 2D Arrays by Summing Values
Merge two 2D arrays by summing values with matching ids using array scanning and hash lookup efficiently.
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.
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…
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…
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.
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…
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…
Form Smallest Number From Two Digit Arrays
Given two arrays of digits, find the smallest possible number formed by one digit from each array.
Find the Substring With Maximum Cost
Find the Substring With Maximum Cost requires calculating substring values using a hash lookup for character costs, with…
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…
Sum of Distances
In this problem, you calculate an array where each element is the sum of absolute differences of indices for equal value…
Sliding Subarray Beauty
Compute the xth smallest negative number in each sliding subarray using array scanning and hash frequency tracking effic…
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…
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.
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…
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 …
Extra Characters in a String
The problem asks for the minimum number of extra characters left after optimally breaking a string into substrings found…
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.
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…
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…
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…
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.
Count Zero Request Servers
Count Zero Request Servers finds the number of servers with zero requests during specific time intervals for a given set…
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.
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.
Relocate Marbles
Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.
Number of Black Blocks
Calculate the number of black blocks in a grid given a list of black cell coordinates.
Minimum Index of a Valid Split
Find the minimum index to split an array such that both subarrays have the same dominant element.
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.
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…
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…
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.
Maximum Elegance of a K-Length Subsequence
Maximize elegance of a k-length subsequence from a list of items with profits and categories.
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.
Maximize the Profit as the Salesman
Determine the maximum profit a salesman can earn by strategically selecting non-overlapping offers on consecutive houses…
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…
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…
Count of Interesting Subarrays
Count all subarrays where the number of elements satisfying a modulo condition equals a target k using efficient prefix …
Points That Intersect With Cars
Count covered integer points by merging overlapping car intervals or marking visited positions on the number line.
Minimum Array Length After Pair Removals
This problem involves minimizing the length of a sorted array by repeatedly removing adjacent pairs of equal elements.
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.
Minimum Operations to Collect Elements
Scan from the end, track seen values from 1 to k, and stop once every required number is collected.
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.
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.
Apply Operations on Array to Maximize Sum of Squares
Maximizing the sum of squares in an array through bitwise operations on selected elements.
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.
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.
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.
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.
High-Access Employees
Identify employees with high system access within one-hour periods based on access logs.
Maximum Strong Pair XOR II
Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.
Find Common Elements Between Two Arrays
Quickly find all numbers that appear in both arrays using scanning and hash lookup to handle duplicates efficiently.
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.
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…
Find Missing and Repeated Values
Find the missing and repeated numbers in an n x n grid using array scanning and hash lookup.
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…
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.
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.
Count Elements With Maximum Frequency
Count Elements With Maximum Frequency is solved by counting each value, tracking the highest count, and summing matching…
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.
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…
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…
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…
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.
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…
Most Frequent Prime
Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…
Split the Array
Determine if an even-length array can be split into two parts with all distinct elements using hash lookup scanning.
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.
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…
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…
Most Frequent IDs
Track the most frequent ID after each update in a dynamic collection of IDs with changing frequencies.
Right Triangles
Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.
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…
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.
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…
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…
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.
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…
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.
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.
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.
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.
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.
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.
Maximum Total Damage With Spell Casting
Calculate the maximum total damage by selectively casting spells while avoiding adjacent power conflicts using array sca…
Delete Nodes From Linked List Present in Array
Remove nodes from a linked list if their values exist in a given array.
Minimum Array Changes to Make Differences Equal
Minimize changes to make array differences equal by replacing elements within a given range.
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.
Design Neighbor Sum Service
Design a service that computes sums for adjacent and diagonal elements in a 2D grid.
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.
Count Almost Equal Pairs II
Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.
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…
Report Spam Message
Determine if a message contains at least two banned words using array scanning and hash lookup.
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.
Sorted GCD Pair Queries
Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…
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…
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.
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.
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…
Find Subtree Sizes After Changes
Calculate the sizes of all subtrees after simultaneous parent changes using array scanning and hash-based counting effic…
Sum of Good Subsequences
Calculate the sum of all good subsequences in an array where consecutive numbers differ by exactly one.
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.
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.
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…
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.
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.
Minimum Number of Operations to Make Elements in Array Distinct
Find the minimum number of operations to make all elements of an array distinct.
Count Special Subsequences
Count the number of special subsequences in an array of positive integers, focusing on efficient array scanning and hash…
Longest Special Path
Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.
Maximum Frequency After Subarray Operation
Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…
Assign Elements to Groups with Constraints
Assign elements to groups by size constraints with a sieve-like approach to find suitable element matches efficiently.
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.
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 …
Design Spreadsheet
Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…
Longest Special Path II
Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…
Maximum Unique Subarray Sum After Deletion
Maximize the sum of a subarray after performing deletions, ensuring elements remain unique.
Closest Equal Element Queries
Find the nearest index with the same value for each query using array scanning combined with hash lookups efficiently.
Properties Graph
Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…
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…
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.
Implement Router
Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.
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.
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.
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…
Find the Most Common Response
Find the most common survey response after eliminating duplicates within each day, using array scanning and hash lookups…
Count Covered Buildings
Determine how many buildings in an n x n city are completely surrounded using array scanning and hash lookup efficiently…
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.
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.
Equal Sum Grid Partition II
Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.
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.
Grid Teleportation Traversal
Find the minimum moves to traverse a 2D grid using standard steps and one-time portal teleports efficiently.
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.
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…
Count Special Triplets
Count Special Triplets requires scanning an array while tracking counts of previous and next values efficiently with has…
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.
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.
Coupon Code Validator
The Coupon Code Validator problem requires filtering and sorting coupons based on specific criteria for validity.
Power Grid Maintenance
Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…
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…
Count Number of Trapezoids II
Count Number of Trapezoids II requires scanning point pairs and hashing slopes to efficiently find parallel sides in arr…