math
math is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.
Interview Signal
Frequently tests problem modeling, edge handling, and verbal clarity.
Common Pitfall
Template-only answers break under follow-up questioning.
Practice Strategy
Practice in 3-5 problem rounds and always review complexity alternatives.
Recommended Progression
Pattern Bridge
High-Pressure Round
Add Two Numbers
Add Two Numbers requires careful linked-list pointer manipulation to sum digits while handling carries efficiently in in…
Reverse Integer
Reverse Integer challenges you to invert the digits of a signed 32-bit integer, handling overflow and negative values ca…
Palindrome Number
Determine if a given integer reads the same forward and backward using a math-driven solution strategy without convertin…
Integer to Roman
Convert a given integer to its Roman numeral representation using hash table mapping and decimal place math operations e…
Roman to Integer
Convert a Roman numeral string into an integer using a hash table and mathematical principles to determine value order.
Divide Two Integers
Solve Divide Two Integers by turning repeated subtraction into bit-shifted chunk subtraction with careful sign and overf…
Multiply Strings
Multiply Strings requires simulating integer multiplication using only string operations without direct numeric conversi…
Rotate Image
Rotate an n x n matrix 90 degrees clockwise in-place using array manipulation and mathematical indexing techniques effic…
Pow(x, n)
Calculate x to the power n efficiently using recursion and exponentiation, handling negative powers and large inputs saf…
Permutation Sequence
Find the kth permutation sequence of a set of numbers using math and recursion to efficiently compute the result.
Unique Paths
Calculate the number of unique paths for a robot to move on an m x n grid with only right and down movements.
Plus One
Given a number as an array of digits, increment it by one and return the updated array of digits.
Add Binary
Add Binary involves summing two binary strings and returning the result as a binary string using math and string manipul…
Sqrt(x)
Solve the Sqrt(x) problem using binary search to find the integer square root of a number without built-in operators.
Climbing Stairs
Climbing Stairs is a classic dynamic programming problem where you calculate distinct ways to reach the top using step t…
Gray Code
Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.
Unique Binary Search Trees
Given n nodes, calculate the number of unique binary search trees (BSTs) that can be formed with values from 1 to n.
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.
Evaluate Reverse Polish Notation
Compute the result of an arithmetic expression in Reverse Polish Notation using a stack to manage operands efficiently.
Fraction to Recurring Decimal
Convert a fraction into a decimal, handling repeating decimals with parentheses around the repeating part.
Excel Sheet Column Title
Convert a positive integer to its corresponding Excel column title using base-26 math and string manipulation efficientl…
Excel Sheet Column Number
This problem requires converting an Excel column title into its corresponding column number by applying a math and strin…
Factorial Trailing Zeroes
Given a number n, find how many trailing zeroes are in n! using a math-driven approach.
Rotate Array
Rotate Array challenges you to shift elements right by k steps using precise two-pointer scanning and invariant tracking…
Happy Number
Determine if a number is happy by repeatedly summing squares of digits using two-pointer scanning to detect cycles effic…
Count Primes
Count all prime numbers less than a given integer n using efficient array and math-based enumeration techniques.
Rectangle Area
Calculate the total area covered by two rectangles using geometry, handling overlaps and avoiding double counting effici…
Basic Calculator
Implement a basic calculator to evaluate mathematical expressions, ensuring correct evaluation with stack-based manageme…
Basic Calculator II
Basic Calculator II evaluates a mathematical expression with operators and integers, handling basic arithmetic with prec…
Power of Two
Determine if a given integer is a power of two using efficient math and bit manipulation techniques with optional recurs…
Number of Digit One
Compute the total number of digit one appearing in all numbers from 0 up to n using state transition dynamic programming…
Different Ways to Add Parentheses
Solve Different Ways to Add Parentheses by splitting on each operator and memoizing every subexpression result list.
Add Digits
Add Digits involves repeatedly summing digits of a number until a single digit is obtained.
Ugly Number
The Ugly Number problem asks you to determine if a number is divisible only by 2, 3, or 5.
Ugly Number II
Find the nth ugly number, where ugly numbers have prime factors limited to 2, 3, and 5.
Missing Number
Find the missing number in an array containing distinct numbers in the range [0, n].
Integer to English Words
Convert a given integer to its English words representation using mathematical logic and string manipulation.
Perfect Squares
Perfect Squares asks for the least number of perfect squares summing to a given integer n using dynamic programming or B…
Expression Add Operators
Expression Add Operators is solved with backtracking that builds multi-digit operands and tracks multiplication preceden…
Nim Game
In Nim Game, determine if you can win given a certain number of stones, assuming optimal play from both players.
Super Ugly Number
Compute the nth super ugly number efficiently using dynamic programming with state transitions based on the given prime …
Bulb Switcher
Bulb Switcher challenges you to find how many bulbs remain on after n toggling rounds using a math-based insight.
Power of Three
Determine if a given integer is a power of three using math and recursion techniques.
Self Crossing
Determine if a path defined by sequential distances on a 2D plane crosses itself using array and math reasoning.
Power of Four
Determine if a given integer is a power of four using math insights and bit manipulation tricks efficiently in code.
Integer Break
Break an integer into the sum of positive integers to maximize the product using dynamic programming.
Count Numbers with Unique Digits
The problem asks to count numbers with unique digits from 0 to 10^n using dynamic programming, math, and backtracking te…
Water and Jug Problem
Determine if two jugs with given capacities can measure an exact target amount using math and DFS strategies efficiently…
Valid Perfect Square
Determine if a given positive integer is a perfect square using a binary search approach over potential square roots eff…
Largest Divisible Subset
Find the largest subset of distinct positive integers where every pair satisfies divisibility using state transition dyn…
Sum of Two Integers
Solve the Sum of Two Integers problem using bit manipulation and math to avoid using the operators + and -.
Super Pow
Compute large exponentiations efficiently using modular arithmetic and divide-and-conquer techniques for this Super Pow …
Guess Number Higher or Lower II
Minimize the maximum cost of guessing a number in a dynamic guessing game using optimal strategies.
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…
Linked List Random Node
Select a random node from a singly linked list ensuring uniform probability using efficient pointer techniques and reser…
Shuffle an Array
Shuffle an Array requires designing a class to randomly permute an integer array while ensuring all permutations are equ…
Elimination Game
Elimination Game uses a systematic removal of numbers with alternating left-right passes, solvable with math and recursi…
Perfect Rectangle
Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…
Rotate Function
Maximize the rotation function by rotating the array and calculating the weighted sum for all rotations.
Random Pick Index
Random Pick Index involves selecting a random index of a target number in an array with possible duplicates.
Nth Digit
Given n, efficiently find the nth digit in the infinite integer sequence using a binary search over valid positions.
Convert a Number to Hexadecimal
Convert a 32-bit integer to its hexadecimal string using math operations and careful string manipulation techniques.
Fizz Buzz
Generate a list from 1 to n replacing multiples of 3 with Fizz, 5 with Buzz, and both with FizzBuzz efficiently.
Add Strings
Given two non-negative integers as strings, sum them and return the result as a string without converting to integers di…
Reconstruct Original Digits from English
This problem asks you to reconstruct digits from an out-of-order English string using hash counting and mathematical ded…
Arranging Coins
Determine the maximum number of complete staircase rows possible with n coins using a binary search approach.
Add Two Numbers II
Add Two Numbers II involves summing two numbers represented as linked lists and returning the result as a new linked lis…
Number of Boomerangs
Compute all valid boomerang tuples in a point set using array scanning with hash maps to track distances efficiently.
Minimum Moves to Equal Array Elements
Compute the fewest steps to make all elements equal by incrementing n-1 array items, applying array and math reasoning.
Poor Pigs
Find the minimum number of pigs required to determine the poisonous bucket within a set time using state transition dyna…
Minimum Moves to Equal Array Elements II
Find the minimum moves to equalize all array elements using increments or decrements with array and math techniques.
Can I Win
Determine if the first player can guarantee a win in a turn-based number selection game using state transition dynamic p…
Implement Rand10() Using Rand7()
Generate uniform random numbers from 1 to 10 using only rand7(), applying rejection sampling for consistent probability …
Total Hamming Distance
Calculate the total Hamming distance between all pairs in an integer array using efficient bit manipulation techniques.
Generate Random Point in a Circle
Generate Random Point in a Circle requires creating a uniform random point inside a circle using math and geometry princ…
Largest Palindrome Product
Find the largest palindromic number from the product of two n-digit integers using math and enumeration efficiently.
Smallest Good Base
Find the smallest good base of an integer n using binary search over the valid answer space.
Predict the Winner
Predict the Winner involves two players taking turns to maximize their score by picking from either end of an array, opt…
Construct the Rectangle
Given an area, design a rectangle with integer length and width optimizing L >= W and minimal difference, using math.
Random Point in Non-overlapping Rectangles
Design an algorithm to pick random points within non-overlapping rectangles using binary search and reservoir sampling.
Base 7
Convert any given integer to its base 7 string representation using efficient math and string manipulation techniques.
Perfect Number
Check if a given number is a perfect number by verifying if it's equal to the sum of its divisors, excluding itself.
Fibonacci Number
Calculate the nth Fibonacci number using state transition dynamic programming and recursive techniques efficiently in in…
Random Flip Matrix
Design an optimized algorithm to randomly flip an index in a matrix, using hash tables and math for efficient random sel…
Continuous Subarray Sum
Identify if any continuous subarray sums to a multiple of k using prefix sums and hash table tracking efficiently.
Random Pick with Weight
Random Pick with Weight requires implementing a probabilistic index picker using prefix sums and binary search efficient…
Complex Number Multiplication
This problem requires multiplying two complex numbers, given in string form, and returning the result in the same format…
Minimum Time Difference
Calculate the smallest time difference between clock points using array manipulation and mathematical conversions effici…
Optimal Division
Maximize the value of an expression by optimally placing parentheses for division operations.
Next Greater Element III
Find the next greater integer using the same digits as a given number with precise two-pointer scanning and invariant tr…
Find the Closest Palindrome
Identify the nearest palindrome to a given integer string, handling ties and large numbers efficiently using math and st…
Erect the Fence
Find the perimeter fence of a garden by determining the outermost trees in a set of given tree coordinates.
Fraction Addition and Subtraction
Solve fraction addition and subtraction by handling expressions, calculating results, and simplifying fractions to irred…
Valid Square
Determine if four given 2D points form a valid square using geometric distance checks and vector validation techniques.
Range Addition II
Range Addition II requires counting maximum values in a matrix after incremental operations using array and math reasoni…
Maximum Product of Three Numbers
Find three numbers in an array whose product is the largest using sorting and careful handling of negative values.
Sum of Square Numbers
Given a non-negative integer c, determine if there are two integers whose squares sum to c.
Solve the Equation
Solve the equation for the variable 'x' and determine its value or state if there is no solution or infinite solutions.
2 Keys Keyboard
Minimize the number of operations to get exactly 'n' characters on the screen using two operations: Copy All and Paste.
Beautiful Arrangement II
Construct a beautiful arrangement of integers from 1 to n with k distinct integers, optimizing for time and space effici…
Kth Smallest Number in Multiplication Table
Find the kth smallest number in an m x n multiplication table using binary search over the valid answer space.
Maximum Swap
Given an integer, swap at most two digits once to produce the largest possible number using greedy digit selection.
Bulb Switcher II
Compute all unique bulb configurations after a fixed number of presses using math and bit manipulation efficiently.
24 Game
Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…
Random Pick with Blacklist
Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…
Self Dividing Numbers
Identify self-dividing numbers in a given range by verifying divisibility against their digits.
Monotone Increasing Digits
Determine the largest number less than or equal to n with digits in non-decreasing order using a greedy, invariant-drive…
Reach a Number
Determine the minimum number of moves to reach a target on an infinite number line using step increments, leveraging bin…
Prime Number of Set Bits in Binary Representation
Count numbers with prime set bits in a binary representation within a given range.
Basic Calculator IV
Simplify mathematical expressions using stack-based state management, handling variables, operators, and polynomial term…
Global and Local Inversions
Determine if every global inversion in a permutation array is also a local inversion using array and math logic efficien…
K-th Symbol in Grammar
Determine the K-th symbol in a recursively generated grammar table using math and bit manipulation patterns efficiently.
Reaching Points
Determine whether it is possible to reach a target point from a start point using repeated additive moves following stri…
Rabbits in Forest
Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.
Transform to Chessboard
Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.
Rotated Digits
Count all integers from 1 to n that transform into a different valid number when each digit is rotated 180 degrees using…
Escape The Ghosts
Escape The Ghosts tests your ability to analyze movements in an infinite grid while racing against ghost positions using…
Preimage Size of Factorial Zeroes Function
Solve for the number of integers whose factorial ends with a specific number of zeroes using binary search techniques.
Split Array With Same Average
Determine whether an integer array can be partitioned into two non-empty subarrays with the same average using dynamic p…
Soup Servings
Compute the probability that soup A empties before soup B using state transition dynamic programming efficiently.
Chalkboard XOR Game
The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…
Largest Triangle Area
Find the area of the largest triangle formed by three distinct points on a 2D plane.
Consecutive Numbers Sum
Find the number of ways to express a number as the sum of consecutive positive integers.
Rectangle Overlap
Determine if two axis-aligned rectangles overlap based on their coordinates.
New 21 Game
Calculate the probability Alice reaches at most n points using state transition dynamic programming efficiently.
Magic Squares In Grid
Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.
Guess the Word
Master the Guess the Word problem by applying array manipulation, match-counting math, and strategic interactive guessin…
Mirror Reflection
Given a square room with mirrors, find which receptor a laser ray will hit first based on two integers, p and q.
Prime Palindrome
The Prime Palindrome problem asks for the smallest prime palindrome greater than or equal to a given integer.
Reordered Power of 2
Determine if a number's digits can be rearranged to form a power of two using counting and hash-based checks.
Stone Game
Stone Game is a dynamic programming problem where players alternate taking stones from piles to maximize their score.
Nth Magical Number
Find the nth magical number divisible by a or b, using binary search to efficiently handle large inputs.
Projection Area of 3D Shapes
Calculate the projection area of a 3D shape defined by a grid of towers with varying heights.
Super Egg Drop
Solve the Super Egg Drop problem using dynamic programming and binary search to minimize the number of moves required to…
Sum of Subsequence Widths
Calculate the sum of widths for all subsequences in an integer array using sorting and combinatorial math efficiently.
Surface Area of 3D Shapes
Solve the Surface Area of 3D Shapes problem using array manipulation and mathematical formulas to calculate surface area…
Orderly Queue
Given a string and integer k, rearrange characters to achieve the lexicographically smallest string using limited rotati…
Numbers At Most N Given Digit Set
The 'Numbers At Most N Given Digit Set' problem requires calculating how many numbers can be formed using a given digit …
Super Palindromes
Count all super-palindromes in a given numeric range, where each is a palindrome and square of a palindrome.
Smallest Range I
Find the smallest score of an array after applying an operation to each element within a given range.
Smallest Range II
Determine the minimum possible difference between the largest and smallest numbers after adjusting each by plus or minus…
Cat and Mouse
Determine the outcome of a two-player Cat and Mouse game on a graph using topological ordering and memoized dynamic prog…
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.
Number of Music Playlists
Solve the Number of Music Playlists problem with dynamic programming, focusing on state transitions and combinatorics to…
Three Equal Parts
Divide a binary array into three contiguous parts such that each part represents the same integer value in binary, using…
Beautiful Array
Beautiful Array builds a valid permutation by recursively separating odd and even positions so no middle-average triple …
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 …
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…
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.
Least Operators to Express Number
Compute the minimum number of arithmetic operators to form a target using repeated x with addition, subtraction, multipl…
Powerful Integers
Find all integers that can be expressed as x^i + y^j up to a given bound using a Hash Table plus Math approach.
Equal Rational Numbers
Given two rational numbers as strings with possible repeating decimals, determine if they represent the same number.
K Closest Points to Origin
Find the k closest points to the origin in a 2D plane using array operations and Euclidean distance calculations efficie…
Largest Perimeter Triangle
Given an integer array, find the largest perimeter of a triangle formed from three of these lengths.
Add to Array-Form of Integer
Compute the sum of an integer and a number represented as an array, efficiently handling digit carries and array travers…
Broken Calculator
Compute the minimum operations to transform startValue into target using doubling and decrementing, leveraging a greedy …
Number of Squareful Arrays
Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…
Clumsy Factorial
Compute the clumsy factorial of a number using a fixed rotation of multiply, divide, add, and subtract operations effici…
Numbers With Repeated Digits
Solve Numbers With Repeated Digits by counting unique-digit numbers up to n, then subtracting from n using digit DP.
Smallest Integer Divisible by K
Find the length of the smallest positive integer divisible by k that consists only of the digit '1'.
Convert to Base -2
Convert any non-negative integer into its base -2 representation using a math-driven iterative remainder strategy.
Divisor Game
Divisor Game is a game theory problem where players take turns subtracting divisors of a number n until one player loses…
Matrix Cells in Distance Order
Compute all matrix cell coordinates sorted by Manhattan distance from a given center using array and math techniques eff…
Moving Stones Until Consecutive
Solve the "Moving Stones Until Consecutive" problem using math and brainteaser patterns by determining the minimum and m…
Valid Boomerang
Determine if three points on a 2D plane form a boomerang, based on distinctness and non-collinearity.
Moving Stones Until Consecutive II
Determine the minimum and maximum moves to make stones consecutive using sliding window and endpoint adjustments efficie…
Robot Bounded In Circle
Determine if a robot following a repeated instruction sequence stays within a bounded circle using math and string simul…
Greatest Common Divisor of Strings
Find the greatest common divisor string between two strings based on the math and string patterns.
Adding Two Negabinary Numbers
Add two numbers represented in negabinary format and return the result in the same format.
Statistics from a Large Sample
Calculate minimum, maximum, mean, median, and mode from a large sample represented by an array of counts.
Distribute Candies to People
Distribute candies to people in a way that follows a mathematical pattern, ensuring the distribution is correct.
Path In Zigzag Labelled Binary Tree
The problem involves finding the path from the root to a node in a zigzag-labelled binary tree.
Maximum of Absolute Value Expression
Calculate the largest sum of absolute differences across two arrays and their indices using an efficient pattern-based a…
N-th Tribonacci Number
Compute the N-th Tribonacci number using state transition dynamic programming with careful memoization and iterative upd…
Stone Game II
Stone Game II is a dynamic programming problem where Alice and Bob alternate taking stones from piles to maximize their …
Day of the Year
Calculate the day number of the year based on a given Gregorian calendar date in the format YYYY-MM-DD.
Prime Arrangements
Calculate the number of valid permutations of 1 to n where prime numbers occupy prime indices using math-driven logic.
Day of the Week
Given a date, calculate the corresponding weekday using a math-based strategy, focusing on modular arithmetic.
Ugly Number III
Find the nth positive integer divisible by a, b, or c using binary search over the answer space efficiently and accurate…
Minimum Cost to Move Chips to The Same Position
Compute the minimum cost to move all chips to one position using parity-based greedy moves efficiently.
Airplane Seat Assignment Probability
Calculate the probability that the last passenger sits in their assigned seat using state transition dynamic programming…
Check If It Is a Straight Line
Determine if a series of coordinates form a straight line on a 2D plane using geometry and mathematical principles.
Find Positive Integer Solution for a Given Equation
Determine all positive integer pairs that satisfy a hidden monotonic function for a given target using binary search ove…
Circular Permutation in Binary Representation
Generate a circular permutation from a range of numbers using backtracking and bit manipulation.
Minimum Swaps to Make Strings Equal
This problem requires determining the minimum number of swaps to make two strings equal by swapping characters between t…
Count Number of Nice Subarrays
The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.
Check If It Is a Good Array
Determine if a given array of positive integers can generate 1 using integer multiples of any subset, leveraging number …
Cells with Odd Values in a Matrix
This problem involves updating a matrix based on given indices and counting cells with odd values afterward.
Minimum Time Visiting All Points
Calculate the minimum seconds required to visit all given 2D points in order using optimal diagonal or straight moves.
Number of Burgers with No Waste of Ingredients
Determine the exact counts of jumbo and small burgers using all tomato and cheese slices without leftovers, applying mat…
Subtract the Product and Sum of Digits of an Integer
Calculate the difference between the product and sum of an integer's digits using a simple math-driven approach for effi…
Convert Binary Number in a Linked List to Integer
Convert a binary number represented in a linked list to its decimal value using efficient pointer manipulation.
Find Numbers with Even Number of Digits
Count the integers in an array that have an even number of digits using a direct array traversal with digit math.
Find N Unique Integers Sum up to Zero
Generate an array of n unique integers that sum to zero using a symmetric pairing strategy to ensure balance.
Verbal Arithmetic Puzzle
Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.
Convert Integer to the Sum of Two No-Zero Integers
Find two positive integers whose sum equals n and neither contains the digit zero, using a direct math-driven approach.
Maximum 69 Number
Maximize a number by flipping at most one digit from 6 to 9 or vice versa.
Reverse Subarray To Maximize Array Value
Maximize the value of an array by reversing a subarray, focusing on greedy choices and invariant validation.
Number of Steps to Reduce a Number to Zero
Reduce a number to zero using bit manipulation and math. Simulate the process step-by-step based on whether the number i…
Angle Between Hands of a Clock
Calculate the smaller angle between the hour and minute hands of a clock based on given time inputs.
Product of the Last K Numbers
Design a data structure to efficiently return the product of the last k numbers in a dynamic integer stream using prefix…
Count All Valid Pickup and Delivery Options
Count all valid pickup and delivery sequences for n orders where deliveries occur after pickups using dynamic programmin…
Number of Days Between Two Dates
Calculate the exact number of days between two dates using string parsing and arithmetic logic with consistent accuracy.
Closest Divisors
Find the closest divisors of num + 1 and num + 2 with minimal absolute difference in this math-driven problem.
Largest Multiple of Three
Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…
Four Divisors
Compute the sum of all divisors for numbers in an array that have exactly four divisors using array and math techniques.
Count Largest Group
Count the number of groups with the largest size by summing digits of numbers from 1 to n using a hash table approach.
Circle and Rectangle Overlapping
Determine if a circle intersects with an axis-aligned rectangle using geometric distance checks efficiently in code.
Stone Game III
Stone Game III is a challenging dynamic programming problem based on game theory and state transition logic.
Find the Minimum Number of Fibonacci Numbers Whose Sum Is K
Find the minimum number of Fibonacci numbers that sum up to a given integer k, using a greedy approach.
Max Difference You Can Get From Changing an Integer
Compute the maximum difference from changing digits in an integer using greedy choices and invariant checks efficiently.
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…
Simplified Fractions
Generate simplified fractions between 0 and 1 with denominators up to a given integer n.
Maximum Number of Darts Inside of a Circular Dartboard
Maximize the number of darts on a circular dartboard given dart positions and radius.
Probability of a Two Boxes Having The Same Number of Distinct Balls
Compute the probability that two boxes contain the same number of distinct balls using careful combinatorial and DP meth…
Allocate Mailboxes
Allocate k mailboxes to houses along a street minimizing total distance using dynamic programming with state transitions…
XOR Operation in an Array
Compute the bitwise XOR of a dynamically generated array using a combination of math and bit manipulation techniques eff…
The kth Factor of n
Find the kth factor of n by scanning divisors carefully or using factor pairs to skip unnecessary checks.
Stone Game IV
Stone Game IV requires predicting the winner using state transition dynamic programming with careful consideration of pe…
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…
Number of Substrings With Only 1s
Calculate the number of contiguous substrings containing only 1s in a binary string using a math and string approach eff…
Best Position for a Service Centre
Find the optimal service center position in a city by minimizing the sum of Euclidean distances to all customers.
Water Bottles
Maximize the number of water bottles you can drink by simulating the exchange process between full and empty bottles.
Count Odd Numbers in an Interval Range
Count Odd Numbers in an Interval Range efficiently using a math-driven formula that avoids unnecessary iteration over la…
Number of Sub-arrays With Odd Sum
Count the number of subarrays with an odd sum using dynamic programming and prefix sum techniques.
Minimum Operations to Make Array Equal
Compute the minimum number of operations to equalize a sequential odd-number array using a precise math-driven approach.
Maximum Number of Coins You Can Get
Solve the Maximum Number of Coins You Can Get using greedy pile selection and invariant validation to maximize your coin…
Stone Game V
In Stone Game V, Alice divides stones into rows to maximize her score, using a dynamic programming approach to try all d…
Number of Ways to Reorder Array to Get Same BST
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
Number of Ways to Split a String
Count the number of ways to split a binary string into three non-empty parts with equal numbers of '1's.
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 …
Sum of All Odd Length Subarrays
Calculate the sum of all odd-length subarrays in a given integer array using efficient array and math strategies.
Maximum Number of Visible Points
Determine the maximum number of points visible from a fixed location within a given angle using a sliding window approac…
Number of Sets of K Non-Overlapping Line Segments
Count all valid arrangements of k non-overlapping line segments on n points using state transition dynamic programming.
Fancy Sequence
Implement a Fancy sequence supporting append, addAll, and multAll operations efficiently using cumulative math design te…
Graph Connectivity With Threshold
In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…
Count Sorted Vowel Strings
Calculate the number of length-n strings with vowels only that are sorted lexicographically using state transitions.
Kth Smallest Instructions
Find the kth smallest lexicographic instruction sequence for reaching a destination in a grid using state transition dyn…
Sell Diminishing-Valued Colored Balls
Maximize total value by greedily selling diminishing-valued colored balls based on inventory and customer orders.
Concatenation of Consecutive Binary Numbers
Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.
Sum of Absolute Differences in a Sorted Array
Calculate the sum of absolute differences between each element and others in a sorted array efficiently.
Stone Game VI
Determine the winner in Stone Game VI using a greedy strategy that accounts for each stone's dual value impact on Alice …
Count of Matches in Tournament
Calculate the total matches in a tournament by simulating rounds and applying simple math rules for advancing teams.
Stone Game VII
Maximize score difference in a two-player turn-based stone removal game using state transition dynamic programming.
Calculate Money in Leetcode Bank
Calculate the total amount of money in the Leetcode bank at the end of the nth day, based on a weekly increasing deposit…
Cat and Mouse II
Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…
Count Ways to Make Array With Product
Determine the number of arrays of size n where the product equals k using prime factorization and combinatorial DP techn…
Building Boxes
Optimize the number of boxes touching the floor in a cubic room using binary search to minimize floor occupancy.
Maximum Number of Balls in a Box
The problem asks you to find the box with the maximum number of balls based on the sum of digits of ball numbers.
Maximum Score From Removing Stones
Maximize the score in a solitaire game by optimally removing stones from three piles with a greedy approach.
Count Number of Homogenous Substrings
This problem requires counting all homogenous substrings in a given string and returning the result modulo 10^9 + 7.
Tree of Coprimes
Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…
Car Fleet II
Car Fleet II involves calculating collision times between cars traveling at different speeds along a one-lane road using…
Check if Number is a Sum of Powers of Three
Determine if a number can be expressed as the sum of distinct powers of three using a math-driven strategy.
Maximize Score After N Operations
Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …
Maximum Value at a Given Index in a Bounded Array
Maximize the value at a given index of an array with constraints using binary search over the valid answer space.
Minimum Number of Operations to Reinitialize a Permutation
Find the minimum number of operations to reinitialize a permutation of size n using specific operations.
Maximize Number of Nice Divisors
Solve Maximize Number of Nice Divisors by splitting primeFactors into mostly 3s and using fast modular exponentiation.
Determine Color of a Chessboard Square
Determine whether a given chessboard square is white or black by converting coordinates using a math plus string approac…
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…
Number of Different Subsequences GCDs
Given an array of positive integers, find the number of different subsequences' GCDs.
Sign of the Product of an Array
Determine the sign of a product from an integer array using a single pass without computing the full product.
Find the Winner of the Circular Game
Find the winner of a circular game by simulating the elimination process with a queue-driven approach.
Queries on Number of Points Inside a Circle
Determine how many 2D points lie within multiple circles using array iteration and Euclidean distance calculations effic…
Minimum Number of Operations to Make String Sorted
Calculate the minimum operations to sort a string using combinatorial math and string manipulation techniques efficientl…
Find XOR Sum of All Pairs Bitwise AND
Compute the XOR sum of all pairwise ANDs between two integer arrays using array and bitwise math techniques efficiently.
Sum of Digits in Base K
Calculate the sum of digits of a number after converting it from base 10 to any given base using a math-driven approach.
Maximum Building Height
Find the maximum building height in a city given height restrictions for specific buildings.
Incremental Memory Leak
Solve Incremental Memory Leak by simulating each second carefully and using math to reason about the crash time bound.
Sum of Floored Pairs
The problem asks to calculate the sum of floor divisions for all pairs in a given integer array, using an efficient meth…
Sum of All Subset XOR Totals
Compute the sum of all subset XOR totals using a backtracking search with pruning for arrays of small size.
Number of Ways to Rearrange Sticks With K Sticks Visible
Calculate the number of arrangements of n uniquely-sized sticks so exactly k sticks are visible using dynamic programmin…
Stone Game VIII
Stone Game VIII requires calculating maximum score difference using state transition dynamic programming on prefix sums …
Get Biggest Three Rhombus Sums in a Grid
Find the three largest distinct rhombus sums from a given grid using array and math techniques.
Egg Drop With 2 Eggs and N Floors
Determine the minimum drops needed to find the critical floor using 2 eggs with optimized state transition dynamic progr…
Minimum Cost to Change the Final Value of Expression
Determine the minimum operations to change a boolean expression's result using state transition dynamic programming effi…
Largest Odd Number in String
Find the largest odd number in a string using a greedy approach with careful digit inspection and invariant checks.
The Number of Full Rounds You Have Played
Solve this math plus string problem to calculate the number of full rounds played in a chess tournament between login an…
Count Ways to Build Rooms in an Ant Colony
Solve the problem of counting distinct ways to build rooms in an ant colony using dynamic programming and topological or…
Count Good Numbers
Count Good Numbers uses a mathematical pattern with recursion to efficiently count digit strings of length n under stric…
Count Square Sum Triples
Count Square Sum Triples asks to find the number of integer triples where a² + b² = c² for values between 1 and n.
Sum Game
Determine if Alice can force a win in the Sum Game by strategically replacing '?' using a greedy and invariant approach.
Three Divisors
Determine if a given integer has exactly three positive divisors.
Minimum Garden Perimeter to Collect Enough Apples
Find the minimum perimeter of a square garden that holds enough apples based on a specific formula involving binary sear…
Minimum Non-Zero Product of the Array Elements
The problem asks to minimize the product of an array after performing bit-swapping operations on its binary representati…
Find Greatest Common Divisor of Array
Find the greatest common divisor of the smallest and largest numbers in an integer array.
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.
GCD Sort of an Array
The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.
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.
The Score of Students Solving Math Expression
Calculate student scores for a single-digit math expression using state transition dynamic programming to track all vali…
Find Missing Observations
Given a set of dice rolls, calculate the missing observations based on the mean and return them or determine if it's imp…
Stone Game IX
In the Stone Game IX problem, Alice and Bob take turns removing stones, and Alice wins if the sum of removed stones is d…
Minimum Operations to Make a Uni-Value Grid
Determine the fewest additions or subtractions of x to make all grid elements identical using array and math logic.
Remove Colored Pieces if Both Neighbors are the Same Color
Alice and Bob play a game removing colored pieces; Alice wins if she makes the last valid move.
Next Greater Numerically Balanced Number
Find the smallest numerically balanced number greater than a given integer using backtracking search and pruning.
Vowels of All Substrings
Compute the total number of vowels in all substrings of a given string using efficient state transition dynamic programm…
Sum of k-Mirror Numbers
This problem requires finding the sum of the n smallest k-mirror numbers by generating palindromes in base-k and base-10…
Detonate the Maximum Bombs
Determine the maximum number of bombs that can be detonated by leveraging chain reactions using graph traversal and DFS …
Number of Smooth Descent Periods of a Stock
Count all contiguous periods where stock prices descend smoothly by exactly one using dynamic programming techniques.
Abbreviating the Product of a Range
Calculate the abbreviated product of integers in a range efficiently using math-driven analysis of trailing zeros and si…
A Number After a Double Reversal
Determine if reversing a number twice returns the original integer by analyzing trailing zeros and digit placement.
Number of Laser Beams in a Bank
Calculate total laser beams in a bank floor plan using array counting and math logic between security devices on differe…
Minimum Moves to Reach Target Score
Calculate the fewest steps to reach a target integer using increments and limited doubles with a greedy strategy.
Number of Ways to Divide a Long Corridor
Calculate the number of ways to split a corridor into sections with exactly two seats using dynamic programming efficien…
Minimum Sum of Four Digit Number After Splitting Digits
Find the minimum sum of two 2-digit numbers by splitting a four-digit number into two integers.
Minimum Cost to Set Cooking Time
Calculate the minimum fatigue to set a microwave cooking time using digit moves and pushes efficiently.
Smallest Value of the Rearranged Number
Rearrange the digits of an integer to minimize its value while avoiding leading zeros, keeping the sign unchanged.
Count Operations to Obtain Zero
Simulate operations on two integers until one becomes zero, counting how many steps it takes to achieve the result.
Find Three Consecutive Integers That Sum to a Given Number
Given a number, find three consecutive integers that sum to it, or return an empty array if no such integers exist.
Maximum Split of Positive Even Integers
Determine the largest set of unique positive even integers that sum to a given finalSum using backtracking and greedy se…
Count Integers With Even Digit Sum
Solve this Easy Math plus Simulation problem by counting numbers whose digit sums are even up to a given limit efficient…
Count Array Pairs Divisible by K
Count Array Pairs Divisible by K requires counting index pairs whose products are divisible by a given number k.
Append K Integers With Minimal Sum
In this problem, you need to append k unique positive integers to a given array nums such that the sum is minimized.
Replace Non-Coprime Numbers in Array
Replace Non-Coprime Numbers in Array uses stack-based state management to iteratively merge adjacent non-coprime integer…
Find Palindrome With Fixed Length
Find the smallest palindromes of a given length for specific queries with mathematical and array manipulation.
Find Triangular Sum of an Array
The problem asks for calculating the triangular sum of an array through repeated pairwise summation.
Add Two Integers
This problem asks to return the sum of two integers within a specific range, focusing on math-driven solution strategy.
Number of Ways to Buy Pens and Pencils
Calculate all distinct ways to spend a fixed total on pens and pencils using a straightforward enumeration strategy.
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 Texts
Calculate the total number of possible original texts from a pressed key sequence using state transition dynamic program…
Find the K-Beauty of a Number
Calculate the k-beauty of a number by counting substrings of length k that divide the original number evenly using a sli…
Minimum Lines to Represent a Line Chart
Determine the fewest lines needed to accurately connect stock price points in a line chart using array and math reasonin…
Sum of Numbers With Units Digit K
Determine the minimum set of positive integers whose units digits match k and sum exactly to num using DP patterns.
Maximum XOR After Operations
Maximize the bitwise XOR of an array after applying a special operation with non-negative integers multiple times.
Count the Number of Ideal Arrays
This problem involves counting the number of ideal arrays of a given length under certain conditions using state transit…
Minimum Deletions to Make Array Divisible
Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.
Number of Zero-Filled Subarrays
Given an array of integers, count the subarrays that consist entirely of 0s.
Maximum Number of Groups Entering a Competition
Determine the maximum number of ordered non-empty student groups for a competition using grades array analysis and binar…
Count Number of Bad Pairs
Count the number of bad pairs in an array where the difference between indices and values does not match.
Minimum Replacements to Sort the Array
Minimize the number of operations to make the array sorted in non-decreasing order by replacing elements with sums of tw…
Count Special Integers
Count the number of special integers in the interval [1, n] where digits of each integer are distinct.
Strictly Palindromic Number
Determine if a number is strictly palindromic in all bases from 2 to n minus 2 using two-pointer scanning and invariant …
Number of Ways to Reach a Position After Exactly k Steps
Find the number of ways to reach a position after exactly k steps on an infinite number line using dynamic programming.
Count Days Spent Together
Count the total number of days Alice and Bob are in Rome together, given their arrival and departure dates.
Smallest Even Multiple
Find the smallest even multiple of a given integer using math and number theory concepts efficiently.
Number of Common Factors
The problem asks to find the number of common factors of two positive integers a and b.
Create Components With Same Value
Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.
Count Number of Distinct Integers After Reverse Operations
This problem requires counting distinct integers after performing reverse operations on each integer in an array.
Sum of Number and Its Reverse
Determine if a non-negative integer can be expressed as the sum of a number and its reverse using enumeration and math r…
Number of Subarrays With GCD Equal to K
Count the number of subarrays with GCD equal to a given value k from a list of integers.
Average Value of Even Numbers That Are Divisible by Three
Find the average of even numbers divisible by 3 from an array of positive integers.
Minimum Addition to Make Integer Beautiful
Find the minimum addition to a number such that its digits sum to a value less than or equal to a given target.
Convert the Temperature
Convert the given Celsius temperature to Kelvin and Fahrenheit using mathematical formulas and return the result in an a…
Number of Subarrays With LCM Equal to K
Find the number of subarrays in an array where the least common multiple (LCM) of the subarray equals a given integer k.
Minimum Cuts to Divide a Circle
Calculate the fewest cuts required to divide a circle into n equal slices using math and geometric reasoning efficiently…
Find the Pivot Integer
Find the Pivot Integer problem challenges you to identify an integer x that balances prefix sums on both sides.
Smallest Value After Replacing With Sum of Prime Factors
Replace a number with the sum of its prime factors until it stabilizes, and return the smallest value.
Minimize the Maximum of Two Arrays
Minimize the Maximum of Two Arrays requires finding the smallest possible maximum number across two arrays, using binary…
Count Anagrams
Learn to count distinct anagrams for a multi-word string using hash tables, math, and combinatorics efficiently.
Count the Digits That Divide a Number
Count the digits that divide a number by checking each digit's divisibility.
Distinct Prime Factors of Product of Array
Find the number of distinct prime factors in the product of an array of integers.
Closest Prime Numbers in Range
Find the two closest prime numbers within a given range using efficient number theory techniques and gap comparisons.
Categorize Box According to Criteria
Classify a box as "Heavy", "Bulky", or "Neither" based on its dimensions and mass using math-driven strategies.
Find Xor-Beauty of Array
Find the xor-beauty of an array by XORing the effective values of all possible triplets of indices.
Difference Between Element Sum and Digit Sum of an Array
Find the absolute difference between element sum and digit sum of an array of integers.
Minimum Operations to Make Array Equal II
Calculate the minimum operations to make two integer arrays equal using greedy adjustments with modular checks efficient…
Check if Point Is Reachable
Determine if a target point is reachable from (1,1) using math-based moves following number theory rules efficiently.
Alternating Digit Sum
Compute the alternating digit sum by applying a sign to each digit and summing efficiently using a math-driven approach.
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…
Count Collisions of Monkeys on a Polygon
Calculate the total number of monkey collisions on a convex polygon using math and recursion efficiently for large n.
Maximum Difference by Remapping a Digit
Find the largest difference by remapping a single digit in a number using a greedy approach to maximize and minimize out…
Count the Number of Square-Free Subsets
Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…
Find the Divisibility Array of a String
Calculate the divisibility array for a string by checking if prefixes are divisible by a given number.
Split With Minimum Sum
Split a positive integer into two parts to minimize their sum using a greedy approach and sorting.
Count Total Number of Colored Cells
The "Count Total Number of Colored Cells" problem requires deriving a formula to compute colored cells based on elapsed …
Pass the Pillow
Pass the Pillow simulates the process of passing an item through a line of people, adjusting the direction based on time…
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…
Distribute Money to Maximum Children
Determine the maximum number of children who can each receive exactly 8 dollars using a greedy approach with validation …
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…
K Items With the Maximum Sum
Select k items from a bag containing 1, 0, and -1 to maximize sum using greedy choice and invariant validation strategie…
Prime Subtraction Operation
Determine if it's possible to make the array strictly increasing using prime subtractions.
Make K-Subarray Sums Equal
Solve Make K-Subarray Sums Equal by grouping circular indices with gcd cycles and minimizing each group to its median.
Prime In Diagonal
Find the largest prime number located on any diagonal of a square matrix using array iteration and prime checking techni…
Calculate Delayed Arrival Time
Calculate the new arrival time of a delayed train in 24-hour format by using basic math operations.
Sum Multiples
Find the sum of integers divisible by 3, 5, or 7 in the range [1, n].
Minimum Number of Operations to Make All Array Elements Equal to 1
Find the minimum number of operations to transform every element of a positive integer array into 1 using gcd operations…
Power of Heroes
Calculate the total power of all non-empty hero groups using state transition dynamic programming efficiently with sorti…
Find the Punishment Number of an Integer
Find the punishment number of a given integer using backtracking search with pruning.
Greatest Common Divisor Traversal
Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.
Count of Integers
Count of Integers challenges you to find the number of integers with a digit sum between a given range using dynamic pro…
Check if The Number is Fascinating
Determine if a 3-digit number is fascinating by checking if the concatenated result of n, 2*n, and 3*n contains all digi…
Total Distance Traveled
Calculate the maximum distance a truck can travel using main and additional fuel tanks with controlled transfers.
Construct the Longest New String
Maximize the length of a string built from AA, BB, and AB without creating triple repeats using DP and greedy logic.
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.
Ways to Split Array Into Good Subarrays
Calculate the number of ways to partition a binary array into good subarrays using state transition dynamic programming …
Prime Pairs With Target Sum
Find all prime number pairs that sum up to a given integer n using an efficient sieve-based array approach.
Find the Maximum Achievable Number
Determine the largest number achievable by repeatedly applying a simple math operation up to t times efficiently.
Maximum Number of Groups With Increasing Length
Maximize the number of groups that can be formed with given usage limits, leveraging binary search for optimal solutions…
Account Balance After Rounded Purchase
Given a purchase amount, calculate the account balance after rounding the purchase to the nearest multiple of 10 and ded…
Insert Greatest Common Divisors in Linked List
The problem involves inserting greatest common divisors between adjacent nodes in a linked list.
Double a Number Represented as a Linked List
Double a number represented as a linked list by carefully managing node values and carries with pointer traversal techni…
Apply Operations to Maximize Score
Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.
Number of Beautiful Integers in the Range
Count all integers in a given range that have equal even and odd digits and are divisible by k using DP.
Determine the Minimum Sum of a k-avoiding Array
Determine the minimum sum of a k-avoiding array by choosing distinct integers such that no pair sums to a given k.
Find the Minimum Possible Sum of a Beautiful Array
Find the minimum possible sum of a beautiful array that satisfies the given conditions with the greedy approach.
Count K-Subsequences of a String With Maximum Beauty
Determine the number of k-length unique subsequences in a string that maximize the sum of character frequencies efficien…
Count Symmetric Integers
Count Symmetric Integers finds numbers where the sum of the first half of digits equals the sum of the second half withi…
Minimum Operations to Make a Special Number
Minimize operations to make a number divisible by 25 by deleting digits. Use greedy choice and invariant validation.
Determine if a Cell Is Reachable at a Given Time
The problem asks if a target cell can be reached from a starting position within a given time on a 2D grid.
String Transformation
Find how many ways string s can be transformed into string t in exactly k operations using suffix rotations.
Maximum Element-Sum of a Complete Subset of Indices
Given a 1-indexed array, select a subset where indices' product is a perfect square, then return the maximum sum.
Maximum Odd Binary Number
Rearrange a binary string to form the largest odd binary number using a greedy approach and least significant bit valida…
Count Valid Paths in a Tree
Count Valid Paths in a Tree involves finding paths with exactly one prime number in a tree of n nodes.
Divisible and Non-divisible Sums Difference
Compute the difference between sums of integers divisible and non-divisible by m using a direct arithmetic approach effi…
Distribute Candies Among Children I
Given two integers n and limit, find the number of ways to distribute n candies among 3 children, with no child receivin…
Distribute Candies Among Children II
Determine how to distribute n candies among 3 children without exceeding a limit on individual candies.
Number of Strings Which Can Be Rearranged to Contain Substring
Calculate how many strings of length n can be rearranged to contain "leet" using dynamic programming and combinatorics.
Maximum Xor Product
Find the maximum value of (a XOR x) * (b XOR x) using greedy bitwise choices and invariant validation.
Matrix Similarity After Cyclic Shifts
Determine if a matrix returns to its original state after performing cyclic row shifts k times using array and math patt…
Count Beautiful Substrings I
Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.
Count Beautiful Substrings II
Count Beautiful Substrings II focuses on finding beautiful substrings with hash tables and number theory techniques.
Count the Number of Infection Sequences
Calculate all valid infection sequences in a line by using array positions and combinatorial math efficiently for n peop…
Double Modular Exponentiation
Solve the Double Modular Exponentiation problem by applying array manipulation and modular arithmetic to find good indic…
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.
Minimum Cost to Make Array Equalindromic
Determine the minimum cost to convert an integer array into a palindromic array using allowed element modifications effi…
Count the Number of Powerful Integers
Count the number of powerful integers in a given range by applying state transition dynamic programming with constraints…
Minimum Moves to Capture The Queen
Determine the fewest moves to capture the black queen using only white pieces with careful position analysis.
Minimize Length of Array Using Operations
Minimize the length of an integer array through a series of operations, using a greedy approach with modular arithmetic.
Minimum Number of Pushes to Type Word I
Calculate the minimum pushes to type a word using a remapped telephone keypad with greedy allocation of letters.
Alice and Bob Playing Flower Game
Alice and Bob play a turn-based game on a circular field with flowers, where players must choose pairs that satisfy pari…
Type of Triangle
Determine the type of triangle from a three-element array using side sums and equality checks efficiently in constant ti…
Find the Number of Ways to Place People I
Calculate how many valid pairs of points can be formed on a 2D plane using array and math enumeration techniques efficie…
Find the Number of Ways to Place People II
Calculate all valid placements of people on a 2D grid ensuring Alice can fence herself with Bob without enclosing others…
Most Frequent Prime
Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…
Find the Largest Area of Square Inside Two Rectangles
Find the largest square area that can fit inside the intersection of two or more rectangles in a 2D plane.
Find the Sum of Encrypted Integers
Compute the sum of encrypted integers by replacing each digit with the largest digit, combining array traversal with dig…
Count Substrings Starting and Ending with Given Character
Given a string and a character, find the total number of substrings that start and end with that character.
Apply Operations to Make Sum of Array Greater Than or Equal to k
Given an array nums, find the minimum number of operations to make the sum of elements greater than or equal to k.
Harshad Number
Given an integer, determine if it is a Harshad number by checking if it's divisible by the sum of its digits.
Water Bottles II
Compute the maximum number of water bottles you can drink by simulating exchanges with step-by-step math logic.
Count Alternating Subarrays
Count all alternating subarrays in a binary array efficiently using array patterns and simple mathematical reasoning.
Minimize Manhattan Distances
Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.
Maximum Prime Difference
Calculate the largest index gap between prime numbers in an array using array traversal and number theory insights effic…
Kth Smallest Amount With Single Denomination Combination
Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…
Right Triangles
Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.
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 Number of Ways to Reach the K-th Stair
Determine the total number of ways to reach the k-th stair using a state transition dynamic programming approach with co…
Find the Child Who Has the Ball After K Seconds
Find the child who holds the ball after k seconds of passing in a queue, considering reversals at both ends.
Find the N-th Value After K Seconds
Solve for the N-th value after K seconds by simulating array updates and using prefix sum techniques.
Find Minimum Operations to Make All Elements Divisible by Three
Find the minimum number of operations to make all elements in an array divisible by three.
Find the Winning Player in Coin Game
In this game between Alice and Bob, players must pick coins summing to 115. Alice starts, and the goal is to determine t…
Vowels Game in a String
Solve the Vowels Game in a String using optimal moves and string analysis to predict the winner efficiently and accurate…
Find if Digit Game Can Be Won
Determine if Alice can guarantee a win in a game by selectively summing single or double-digit numbers from an array.
Find the Count of Numbers Which Are Not Special
Count the numbers between two integers that are not special, where special numbers are squares of primes.
Check if the Rectangle Corner Is Reachable
Determine if there is a valid path from the bottom-left to top-right of a rectangle while avoiding circles.
Find the Count of Monotonic Pairs I
Compute the number of monotonic pairs in an integer array using state transition dynamic programming efficiently.
Find the Count of Monotonic Pairs II
This problem involves finding the count of monotonic pairs in an array using dynamic programming and combinatorics techn…
Find the Largest Palindrome Divisible by K
Compute the largest n-digit integer divisible by k that forms a palindrome using state transition dynamic programming te…
Final Array State After K Multiplication Operations I
Solve the problem of determining the final state of an array after multiple multiplication operations using a priority q…
Find the Key of the Numbers
Determine the four-digit key from three given numbers using a precise math-driven approach for exact digit alignment.
Find the Count of Good Integers
Count good integers by rearranging digits to form k-palindromic numbers, leveraging hash tables and math techniques.
Check if Two Chessboard Squares Have the Same Color
Determine if two chessboard squares share the same color using coordinate math and simple string manipulation for quick …
Convert Date to Binary
Convert a given Gregorian date string to its binary format by transforming year, month, and day individually without lea…
Maximum Number of Moves to Kill All Pawns
Calculate the maximum number of moves to eliminate all pawns using BFS, bitmasking, and precise array position math effi…
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…
Minimum Number of Seconds to Make Mountain Height Zero
Determine the minimum seconds required to reduce a mountain to zero height using simultaneous workers efficiently.
Minimum Element After Replacement With Digit Sum
Replace each number with its digit sum and return the smallest resulting value, using array plus math techniques efficie…
Find the K-th Character in String Game I
Find the K-th character in a progressively built string using math and bit manipulation efficiently.
Find the K-th Character in String Game II
Find the K-th character in a string game using bit manipulation and recursion, optimizing performance for large k values…
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 the Number of Possible Ways for an Event
Given n performers, x stages, and y scores, calculate the number of possible ways to assign performers and score bands.
Minimum Division Operations to Make Array Non Decreasing
Determine the minimum number of division operations to make an array non-decreasing using a greedy and invariant-based s…
Find the Maximum Factor Score of Array
Calculate the maximum factor score of an integer array by optionally removing one element using LCM and GCD computations…
Total Characters in String After Transformations I
Calculate the total number of characters in a string after repeated transformations using dynamic programming and freque…
Find the Number of Subsequences With Equal GCD
Count all pairs of non-empty subsequences in an integer array whose elements share the same greatest common divisor effi…
Total Characters in String After Transformations II
Calculate the length of a string after repeated transformations using state transition dynamic programming for large t v…
Count Number of Balanced Permutations
Determine how many distinct permutations of a digit string are balanced using state transition dynamic programming effic…
Smallest Divisible Digit Product I
Find the smallest number greater than or equal to n whose digit product is divisible by t.
Smallest Divisible Digit Product II
Find the smallest zero-free number at least as large as num whose digits multiply to a product divisible by t using care…
Count K-Reducible Numbers Less Than N
This problem challenges you to count the K-reducible numbers less than a given binary integer using dynamic programming.
Stone Removal Game
Alice and Bob play a game of stone removal. Alice goes first, and the winner is the player who can make a move until the…
Smallest Number With All Set Bits
Find the smallest number greater than or equal to n with all set bits in its binary representation.
Digit Operations to Make Two Integers Equal
Transform n into m using allowed digit operations without creating primes, applying math and graph strategies efficientl…
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 Area Rectangle With Point Constraints I
Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.
Maximum Area Rectangle With Point Constraints II
Find the largest rectangle on a plane using given points while avoiding any interior points and optimizing with math and…
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.
Count Special Subsequences
Count the number of special subsequences in an array of positive integers, focusing on efficient array scanning and hash…
Count the Number of Arrays with K Matching Adjacent Elements
Count the number of valid arrays with exactly k adjacent elements that are equal, using math and combinatorics technique…
Maximum Subarray With Equal Products
This problem involves finding the longest subarray where the product equals the LCM multiplied by the GCD, leveraging a …
Manhattan Distances of All Arrangements of Pieces
This problem challenges you to calculate Manhattan distances in all valid arrangements of identical pieces on a grid.
Maximum and Minimum Sums of at Most Size K Subsequences
Find the sum of the maximum and minimum elements of subsequences with at most k elements, using dynamic programming.
Maximum and Minimum Sums of at Most Size K Subarrays
Compute the sum of maximum and minimum values in all subarrays up to size k using efficient stack-based state management…
Count Partitions with Even Sum Difference
Count the number of partitions with an even sum difference from an array of integers.
Count Mentions Per User
Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…
Maximum Manhattan Distance After K Changes
Solve Maximum Manhattan Distance After K Changes by scanning prefixes and testing the four diagonal target pairs with li…
Minimum Increments for Target Multiples in an Array
This problem involves incrementing elements of an array to make sure each target element has at least one multiple in th…
Check If Digits Are Equal in String After Operations I
Simulate repeated adjacent digit sums modulo 10 until two digits remain, then check whether those final digits match.
Check If Digits Are Equal in String After Operations II
Determine if repeated digit-sum operations on a numeric string reduce it to two equal digits using math and string techn…
Find the Number of Copy Arrays
Find the number of possible arrays by leveraging bounds and math in this array-based problem.
Permutations IV
Find the k-th alternating permutation of numbers 1 to n, ensuring no adjacent numbers share parity, using array and math…
Maximum Containers on a Ship
Determine the maximum number of containers that can be loaded onto a ship's deck without exceeding weight limits.
Minimum Operations to Make Array Elements Zero
Minimize operations to reduce array elements to zero, focusing on array manipulation, math, and bit operations for effic…
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 Operations to Make Array Sum Divisible by K
This problem asks you to find the minimum operations to make the sum of an array divisible by a given integer k.
Number of Unique XOR Triplets I
Calculate all unique XOR triplet values in a permutation array using array traversal and bit manipulation techniques eff…
Number of Unique XOR Triplets II
Count all unique XOR results from triplets in an integer array using array traversal and bit manipulation techniques eff…
Find Closest Person
Determine which of two people reaches a third person first using a simple math-driven distance comparison strategy.
Smallest Palindromic Rearrangement II
Find the k-th lexicographically smallest palindromic rearrangement of a given palindromic string s.
Count Numbers with Non-Decreasing Digits
Count all integers between l and r whose digits never decrease in base b using state transition dynamic programming effi…
Find X Value of Array I
Determine the x-value of an array using state transition dynamic programming to count valid prefix-suffix operations eff…
Find X Value of Array II
The "Find X Value of Array II" problem requires calculating the number of ways to remove a suffix from an array such tha…
Maximum Product of Two Digits
Find the highest product obtainable from any two digits of a given positive integer using math and sorting techniques ef…
Find Sum of Array Product of Magical Sequences
Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…
Smallest Index With Digit Sum Equal to Index
Find the smallest index in an array where the sum of the digits equals the index.
Sum of Largest Prime Substrings
Compute the sum of the three largest unique primes from all substrings using hash table plus math efficiently.
Number of Ways to Assign Edge Weights I
Calculate the number of valid edge weight assignments in a tree using DFS and binary-tree traversal with careful state t…
Number of Ways to Assign Edge Weights II
This problem involves assigning edge weights in a tree and calculating the cost of paths based on these weights.
Find Minimum Log Transportation Cost
Calculate the minimum cost to transport two logs using a math-driven strategy considering cutting costs and truck limits…
Maximize Count of Distinct Primes After Split
Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…
Maximize Subarray GCD Score
Maximize Subarray GCD Score focuses on maximizing a subarray's score by using at most k doubling operations on an array …
Count the Number of Computer Unlocking Permutations
Calculate the total valid unlocking sequences for computers based on their complexity using array and combinatorics logi…
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.
Count Prime-Gap Balanced Subarrays
Count the number of prime-gap balanced subarrays in an integer array using sliding window techniques and running state u…
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.
Hexadecimal and Hexatrigesimal Conversion
Solve Hexadecimal and Hexatrigesimal Conversion by converting n squared to base 16 and n cubed to base 36, then joining …
Minimum Stability Factor of Array
The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…
Minimum Moves to Reach Target in Grid
Find the minimum number of moves to reach a target point from a start point on a 2D grid with a math-driven solution.
Split Array by Prime Indices
Split Array by Prime Indices challenges you to separate elements at prime positions and minimize the absolute sum differ…
Number of Integers With Popcount-Depth Equal to K I
Calculate the number of integers in a given range with a specific popcount-depth using state transition dynamic programm…
Check Divisibility by Digit Sum and Product
Determine if a positive integer is divisible by the sum of its digits plus their product using a math-driven strategy.
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…
Partition Array for Maximum XOR and AND
Partition the array into three subsequences to maximize XOR and AND operations with a greedy approach.