LeetCodechevron_rightCategorieschevron_rightmath
calculate

math

528 problems
Easy: 142Medium: 243Hard: 143

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

#TitleDifficulty
2

Add Two Numbers

Add Two Numbers requires careful linked-list pointer manipulation to sum digits while handling carries efficiently in in…

Medium
7

Reverse Integer

Reverse Integer challenges you to invert the digits of a signed 32-bit integer, handling overflow and negative values ca…

Medium
9

Palindrome Number

Determine if a given integer reads the same forward and backward using a math-driven solution strategy without convertin…

Easy
12

Integer to Roman

Convert a given integer to its Roman numeral representation using hash table mapping and decimal place math operations e…

Medium
13

Roman to Integer

Convert a Roman numeral string into an integer using a hash table and mathematical principles to determine value order.

Easy
29

Divide Two Integers

Solve Divide Two Integers by turning repeated subtraction into bit-shifted chunk subtraction with careful sign and overf…

Medium
43

Multiply Strings

Multiply Strings requires simulating integer multiplication using only string operations without direct numeric conversi…

Medium
48

Rotate Image

Rotate an n x n matrix 90 degrees clockwise in-place using array manipulation and mathematical indexing techniques effic…

Medium
50

Pow(x, n)

Calculate x to the power n efficiently using recursion and exponentiation, handling negative powers and large inputs saf…

Medium
60

Permutation Sequence

Find the kth permutation sequence of a set of numbers using math and recursion to efficiently compute the result.

Hard
62

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.

Medium
66

Plus One

Given a number as an array of digits, increment it by one and return the updated array of digits.

Easy
67

Add Binary

Add Binary involves summing two binary strings and returning the result as a binary string using math and string manipul…

Easy
69

Sqrt(x)

Solve the Sqrt(x) problem using binary search to find the integer square root of a number without built-in operators.

Easy
70

Climbing Stairs

Climbing Stairs is a classic dynamic programming problem where you calculate distinct ways to reach the top using step t…

Easy
89

Gray Code

Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.

Medium
96

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.

Medium
149

Max Points on a Line

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

Hard
150

Evaluate Reverse Polish Notation

Compute the result of an arithmetic expression in Reverse Polish Notation using a stack to manage operands efficiently.

Medium
166

Fraction to Recurring Decimal

Convert a fraction into a decimal, handling repeating decimals with parentheses around the repeating part.

Medium
168

Excel Sheet Column Title

Convert a positive integer to its corresponding Excel column title using base-26 math and string manipulation efficientl…

Easy
171

Excel Sheet Column Number

This problem requires converting an Excel column title into its corresponding column number by applying a math and strin…

Easy
172

Factorial Trailing Zeroes

Given a number n, find how many trailing zeroes are in n! using a math-driven approach.

Medium
189

Rotate Array

Rotate Array challenges you to shift elements right by k steps using precise two-pointer scanning and invariant tracking…

Medium
202

Happy Number

Determine if a number is happy by repeatedly summing squares of digits using two-pointer scanning to detect cycles effic…

Easy
204

Count Primes

Count all prime numbers less than a given integer n using efficient array and math-based enumeration techniques.

Medium
223

Rectangle Area

Calculate the total area covered by two rectangles using geometry, handling overlaps and avoiding double counting effici…

Medium
224

Basic Calculator

Implement a basic calculator to evaluate mathematical expressions, ensuring correct evaluation with stack-based manageme…

Hard
227

Basic Calculator II

Basic Calculator II evaluates a mathematical expression with operators and integers, handling basic arithmetic with prec…

Medium
231

Power of Two

Determine if a given integer is a power of two using efficient math and bit manipulation techniques with optional recurs…

Easy
233

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…

Hard
241

Different Ways to Add Parentheses

Solve Different Ways to Add Parentheses by splitting on each operator and memoizing every subexpression result list.

Medium
258

Add Digits

Add Digits involves repeatedly summing digits of a number until a single digit is obtained.

Easy
263

Ugly Number

The Ugly Number problem asks you to determine if a number is divisible only by 2, 3, or 5.

Easy
264

Ugly Number II

Find the nth ugly number, where ugly numbers have prime factors limited to 2, 3, and 5.

Medium
268

Missing Number

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

Easy
273

Integer to English Words

Convert a given integer to its English words representation using mathematical logic and string manipulation.

Hard
279

Perfect Squares

Perfect Squares asks for the least number of perfect squares summing to a given integer n using dynamic programming or B…

Medium
282

Expression Add Operators

Expression Add Operators is solved with backtracking that builds multi-digit operands and tracks multiplication preceden…

Hard
292

Nim Game

In Nim Game, determine if you can win given a certain number of stones, assuming optimal play from both players.

Easy
313

Super Ugly Number

Compute the nth super ugly number efficiently using dynamic programming with state transitions based on the given prime …

Medium
319

Bulb Switcher

Bulb Switcher challenges you to find how many bulbs remain on after n toggling rounds using a math-based insight.

Medium
326

Power of Three

Determine if a given integer is a power of three using math and recursion techniques.

Easy
335

Self Crossing

Determine if a path defined by sequential distances on a 2D plane crosses itself using array and math reasoning.

Hard
342

Power of Four

Determine if a given integer is a power of four using math insights and bit manipulation tricks efficiently in code.

Easy
343

Integer Break

Break an integer into the sum of positive integers to maximize the product using dynamic programming.

Medium
357

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…

Medium
365

Water and Jug Problem

Determine if two jugs with given capacities can measure an exact target amount using math and DFS strategies efficiently…

Medium
367

Valid Perfect Square

Determine if a given positive integer is a perfect square using a binary search approach over potential square roots eff…

Easy
368

Largest Divisible Subset

Find the largest subset of distinct positive integers where every pair satisfies divisibility using state transition dyn…

Medium
371

Sum of Two Integers

Solve the Sum of Two Integers problem using bit manipulation and math to avoid using the operators + and -.

Medium
372

Super Pow

Compute large exponentiations efficiently using modular arithmetic and divide-and-conquer techniques for this Super Pow …

Medium
375

Guess Number Higher or Lower II

Minimize the maximum cost of guessing a number in a dynamic guessing game using optimal strategies.

Medium
380

Insert Delete GetRandom O(1)

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

Medium
381

Insert Delete GetRandom O(1) - Duplicates allowed

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

Hard
382

Linked List Random Node

Select a random node from a singly linked list ensuring uniform probability using efficient pointer techniques and reser…

Medium
384

Shuffle an Array

Shuffle an Array requires designing a class to randomly permute an integer array while ensuring all permutations are equ…

Medium
390

Elimination Game

Elimination Game uses a systematic removal of numbers with alternating left-right passes, solvable with math and recursi…

Medium
391

Perfect Rectangle

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

Hard
396

Rotate Function

Maximize the rotation function by rotating the array and calculating the weighted sum for all rotations.

Medium
398

Random Pick Index

Random Pick Index involves selecting a random index of a target number in an array with possible duplicates.

Medium
400

Nth Digit

Given n, efficiently find the nth digit in the infinite integer sequence using a binary search over valid positions.

Medium
405

Convert a Number to Hexadecimal

Convert a 32-bit integer to its hexadecimal string using math operations and careful string manipulation techniques.

Easy
412

Fizz Buzz

Generate a list from 1 to n replacing multiples of 3 with Fizz, 5 with Buzz, and both with FizzBuzz efficiently.

Easy
415

Add Strings

Given two non-negative integers as strings, sum them and return the result as a string without converting to integers di…

Easy
423

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…

Medium
441

Arranging Coins

Determine the maximum number of complete staircase rows possible with n coins using a binary search approach.

Easy
445

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…

Medium
447

Number of Boomerangs

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

Medium
453

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.

Medium
458

Poor Pigs

Find the minimum number of pigs required to determine the poisonous bucket within a set time using state transition dyna…

Hard
462

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.

Medium
464

Can I Win

Determine if the first player can guarantee a win in a turn-based number selection game using state transition dynamic p…

Medium
470

Implement Rand10() Using Rand7()

Generate uniform random numbers from 1 to 10 using only rand7(), applying rejection sampling for consistent probability …

Medium
477

Total Hamming Distance

Calculate the total Hamming distance between all pairs in an integer array using efficient bit manipulation techniques.

Medium
478

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…

Medium
479

Largest Palindrome Product

Find the largest palindromic number from the product of two n-digit integers using math and enumeration efficiently.

Hard
483

Smallest Good Base

Find the smallest good base of an integer n using binary search over the valid answer space.

Hard
486

Predict the Winner

Predict the Winner involves two players taking turns to maximize their score by picking from either end of an array, opt…

Medium
492

Construct the Rectangle

Given an area, design a rectangle with integer length and width optimizing L >= W and minimal difference, using math.

Easy
497

Random Point in Non-overlapping Rectangles

Design an algorithm to pick random points within non-overlapping rectangles using binary search and reservoir sampling.

Medium
504

Base 7

Convert any given integer to its base 7 string representation using efficient math and string manipulation techniques.

Easy
507

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.

Easy
509

Fibonacci Number

Calculate the nth Fibonacci number using state transition dynamic programming and recursive techniques efficiently in in…

Easy
519

Random Flip Matrix

Design an optimized algorithm to randomly flip an index in a matrix, using hash tables and math for efficient random sel…

Medium
523

Continuous Subarray Sum

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

Medium
528

Random Pick with Weight

Random Pick with Weight requires implementing a probabilistic index picker using prefix sums and binary search efficient…

Medium
537

Complex Number Multiplication

This problem requires multiplying two complex numbers, given in string form, and returning the result in the same format…

Medium
539

Minimum Time Difference

Calculate the smallest time difference between clock points using array manipulation and mathematical conversions effici…

Medium
553

Optimal Division

Maximize the value of an expression by optimally placing parentheses for division operations.

Medium
556

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…

Medium
564

Find the Closest Palindrome

Identify the nearest palindrome to a given integer string, handling ties and large numbers efficiently using math and st…

Hard
587

Erect the Fence

Find the perimeter fence of a garden by determining the outermost trees in a set of given tree coordinates.

Hard
592

Fraction Addition and Subtraction

Solve fraction addition and subtraction by handling expressions, calculating results, and simplifying fractions to irred…

Medium
593

Valid Square

Determine if four given 2D points form a valid square using geometric distance checks and vector validation techniques.

Medium
598

Range Addition II

Range Addition II requires counting maximum values in a matrix after incremental operations using array and math reasoni…

Easy
628

Maximum Product of Three Numbers

Find three numbers in an array whose product is the largest using sorting and careful handling of negative values.

Easy
633

Sum of Square Numbers

Given a non-negative integer c, determine if there are two integers whose squares sum to c.

Medium
640

Solve the Equation

Solve the equation for the variable 'x' and determine its value or state if there is no solution or infinite solutions.

Medium
650

2 Keys Keyboard

Minimize the number of operations to get exactly 'n' characters on the screen using two operations: Copy All and Paste.

Medium
667

Beautiful Arrangement II

Construct a beautiful arrangement of integers from 1 to n with k distinct integers, optimizing for time and space effici…

Medium
668

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.

Hard
670

Maximum Swap

Given an integer, swap at most two digits once to produce the largest possible number using greedy digit selection.

Medium
672

Bulb Switcher II

Compute all unique bulb configurations after a fixed number of presses using math and bit manipulation efficiently.

Medium
679

24 Game

Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…

Hard
710

Random Pick with Blacklist

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

Hard
728

Self Dividing Numbers

Identify self-dividing numbers in a given range by verifying divisibility against their digits.

Easy
738

Monotone Increasing Digits

Determine the largest number less than or equal to n with digits in non-decreasing order using a greedy, invariant-drive…

Medium
754

Reach a Number

Determine the minimum number of moves to reach a target on an infinite number line using step increments, leveraging bin…

Medium
762

Prime Number of Set Bits in Binary Representation

Count numbers with prime set bits in a binary representation within a given range.

Easy
770

Basic Calculator IV

Simplify mathematical expressions using stack-based state management, handling variables, operators, and polynomial term…

Hard
775

Global and Local Inversions

Determine if every global inversion in a permutation array is also a local inversion using array and math logic efficien…

Medium
779

K-th Symbol in Grammar

Determine the K-th symbol in a recursively generated grammar table using math and bit manipulation patterns efficiently.

Medium
780

Reaching Points

Determine whether it is possible to reach a target point from a start point using repeated additive moves following stri…

Hard
781

Rabbits in Forest

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

Medium
782

Transform to Chessboard

Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.

Hard
788

Rotated Digits

Count all integers from 1 to n that transform into a different valid number when each digit is rotated 180 degrees using…

Medium
789

Escape The Ghosts

Escape The Ghosts tests your ability to analyze movements in an infinite grid while racing against ghost positions using…

Medium
793

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.

Hard
805

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…

Hard
808

Soup Servings

Compute the probability that soup A empties before soup B using state transition dynamic programming efficiently.

Medium
810

Chalkboard XOR Game

The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…

Hard
812

Largest Triangle Area

Find the area of the largest triangle formed by three distinct points on a 2D plane.

Easy
829

Consecutive Numbers Sum

Find the number of ways to express a number as the sum of consecutive positive integers.

Hard
836

Rectangle Overlap

Determine if two axis-aligned rectangles overlap based on their coordinates.

Easy
837

New 21 Game

Calculate the probability Alice reaches at most n points using state transition dynamic programming efficiently.

Medium
840

Magic Squares In Grid

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

Medium
843

Guess the Word

Master the Guess the Word problem by applying array manipulation, match-counting math, and strategic interactive guessin…

Hard
858

Mirror Reflection

Given a square room with mirrors, find which receptor a laser ray will hit first based on two integers, p and q.

Medium
866

Prime Palindrome

The Prime Palindrome problem asks for the smallest prime palindrome greater than or equal to a given integer.

Medium
869

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.

Medium
877

Stone Game

Stone Game is a dynamic programming problem where players alternate taking stones from piles to maximize their score.

Medium
878

Nth Magical Number

Find the nth magical number divisible by a or b, using binary search to efficiently handle large inputs.

Hard
883

Projection Area of 3D Shapes

Calculate the projection area of a 3D shape defined by a grid of towers with varying heights.

Easy
887

Super Egg Drop

Solve the Super Egg Drop problem using dynamic programming and binary search to minimize the number of moves required to…

Hard
891

Sum of Subsequence Widths

Calculate the sum of widths for all subsequences in an integer array using sorting and combinatorial math efficiently.

Hard
892

Surface Area of 3D Shapes

Solve the Surface Area of 3D Shapes problem using array manipulation and mathematical formulas to calculate surface area…

Easy
899

Orderly Queue

Given a string and integer k, rearrange characters to achieve the lexicographically smallest string using limited rotati…

Hard
902

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 …

Hard
906

Super Palindromes

Count all super-palindromes in a given numeric range, where each is a palindrome and square of a palindrome.

Hard
908

Smallest Range I

Find the smallest score of an array after applying an operation to each element within a given range.

Easy
910

Smallest Range II

Determine the minimum possible difference between the largest and smallest numbers after adjusting each by plus or minus…

Medium
913

Cat and Mouse

Determine the outcome of a two-player Cat and Mouse game on a graph using topological ordering and memoized dynamic prog…

Hard
914

X of a Kind in a Deck of Cards

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

Easy
920

Number of Music Playlists

Solve the Number of Music Playlists problem with dynamic programming, focusing on state transitions and combinatorics to…

Hard
927

Three Equal Parts

Divide a binary array into three contiguous parts such that each part represents the same integer value in binary, using…

Hard
932

Beautiful Array

Beautiful Array builds a valid permutation by recursively separating odd and even positions so no middle-average triple …

Medium
939

Minimum Area Rectangle

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

Medium
952

Largest Component Size by Common Factor

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

Hard
957

Prison Cells After N Days

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

Medium
963

Minimum Area Rectangle II

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

Medium
964

Least Operators to Express Number

Compute the minimum number of arithmetic operators to form a target using repeated x with addition, subtraction, multipl…

Hard
970

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.

Medium
972

Equal Rational Numbers

Given two rational numbers as strings with possible repeating decimals, determine if they represent the same number.

Hard
973

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…

Medium
976

Largest Perimeter Triangle

Given an integer array, find the largest perimeter of a triangle formed from three of these lengths.

Easy
989

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…

Easy
991

Broken Calculator

Compute the minimum operations to transform startValue into target using doubling and decrementing, leveraging a greedy …

Medium
996

Number of Squareful Arrays

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

Hard
1006

Clumsy Factorial

Compute the clumsy factorial of a number using a fixed rotation of multiply, divide, add, and subtract operations effici…

Medium
1012

Numbers With Repeated Digits

Solve Numbers With Repeated Digits by counting unique-digit numbers up to n, then subtracting from n using digit DP.

Hard
1015

Smallest Integer Divisible by K

Find the length of the smallest positive integer divisible by k that consists only of the digit '1'.

Medium
1017

Convert to Base -2

Convert any non-negative integer into its base -2 representation using a math-driven iterative remainder strategy.

Medium
1025

Divisor Game

Divisor Game is a game theory problem where players take turns subtracting divisors of a number n until one player loses…

Easy
1030

Matrix Cells in Distance Order

Compute all matrix cell coordinates sorted by Manhattan distance from a given center using array and math techniques eff…

Easy
1033

Moving Stones Until Consecutive

Solve the "Moving Stones Until Consecutive" problem using math and brainteaser patterns by determining the minimum and m…

Medium
1037

Valid Boomerang

Determine if three points on a 2D plane form a boomerang, based on distinctness and non-collinearity.

Easy
1040

Moving Stones Until Consecutive II

Determine the minimum and maximum moves to make stones consecutive using sliding window and endpoint adjustments efficie…

Medium
1041

Robot Bounded In Circle

Determine if a robot following a repeated instruction sequence stays within a bounded circle using math and string simul…

Medium
1071

Greatest Common Divisor of Strings

Find the greatest common divisor string between two strings based on the math and string patterns.

Easy
1073

Adding Two Negabinary Numbers

Add two numbers represented in negabinary format and return the result in the same format.

Medium
1093

Statistics from a Large Sample

Calculate minimum, maximum, mean, median, and mode from a large sample represented by an array of counts.

Medium
1103

Distribute Candies to People

Distribute candies to people in a way that follows a mathematical pattern, ensuring the distribution is correct.

Easy
1104

Path In Zigzag Labelled Binary Tree

The problem involves finding the path from the root to a node in a zigzag-labelled binary tree.

Medium
1131

Maximum of Absolute Value Expression

Calculate the largest sum of absolute differences across two arrays and their indices using an efficient pattern-based a…

Medium
1137

N-th Tribonacci Number

Compute the N-th Tribonacci number using state transition dynamic programming with careful memoization and iterative upd…

Easy
1140

Stone Game II

Stone Game II is a dynamic programming problem where Alice and Bob alternate taking stones from piles to maximize their …

Medium
1154

Day of the Year

Calculate the day number of the year based on a given Gregorian calendar date in the format YYYY-MM-DD.

Easy
1175

Prime Arrangements

Calculate the number of valid permutations of 1 to n where prime numbers occupy prime indices using math-driven logic.

Easy
1185

Day of the Week

Given a date, calculate the corresponding weekday using a math-based strategy, focusing on modular arithmetic.

Easy
1201

Ugly Number III

Find the nth positive integer divisible by a, b, or c using binary search over the answer space efficiently and accurate…

Medium
1217

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.

Easy
1227

Airplane Seat Assignment Probability

Calculate the probability that the last passenger sits in their assigned seat using state transition dynamic programming…

Medium
1232

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.

Easy
1237

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…

Medium
1238

Circular Permutation in Binary Representation

Generate a circular permutation from a range of numbers using backtracking and bit manipulation.

Medium
1247

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…

Medium
1248

Count Number of Nice Subarrays

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

Medium
1250

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 …

Hard
1252

Cells with Odd Values in a Matrix

This problem involves updating a matrix based on given indices and counting cells with odd values afterward.

Easy
1266

Minimum Time Visiting All Points

Calculate the minimum seconds required to visit all given 2D points in order using optimal diagonal or straight moves.

Easy
1276

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…

Medium
1281

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…

Easy
1290

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.

Easy
1295

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.

Easy
1304

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.

Easy
1307

Verbal Arithmetic Puzzle

Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.

Hard
1317

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.

Easy
1323

Maximum 69 Number

Maximize a number by flipping at most one digit from 6 to 9 or vice versa.

Easy
1330

Reverse Subarray To Maximize Array Value

Maximize the value of an array by reversing a subarray, focusing on greedy choices and invariant validation.

Hard
1342

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…

Easy
1344

Angle Between Hands of a Clock

Calculate the smaller angle between the hour and minute hands of a clock based on given time inputs.

Medium
1352

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…

Medium
1359

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…

Hard
1360

Number of Days Between Two Dates

Calculate the exact number of days between two dates using string parsing and arithmetic logic with consistent accuracy.

Easy
1362

Closest Divisors

Find the closest divisors of num + 1 and num + 2 with minimal absolute difference in this math-driven problem.

Medium
1363

Largest Multiple of Three

Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…

Hard
1390

Four Divisors

Compute the sum of all divisors for numbers in an array that have exactly four divisors using array and math techniques.

Medium
1399

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.

Easy
1401

Circle and Rectangle Overlapping

Determine if a circle intersects with an axis-aligned rectangle using geometric distance checks efficiently in code.

Medium
1406

Stone Game III

Stone Game III is a challenging dynamic programming problem based on game theory and state transition logic.

Hard
1414

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.

Medium
1432

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.

Medium
1442

Count Triplets That Can Form Two Arrays of Equal XOR

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

Medium
1447

Simplified Fractions

Generate simplified fractions between 0 and 1 with denominators up to a given integer n.

Medium
1453

Maximum Number of Darts Inside of a Circular Dartboard

Maximize the number of darts on a circular dartboard given dart positions and radius.

Hard
1467

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…

Hard
1478

Allocate Mailboxes

Allocate k mailboxes to houses along a street minimizing total distance using dynamic programming with state transitions…

Hard
1486

XOR Operation in an Array

Compute the bitwise XOR of a dynamically generated array using a combination of math and bit manipulation techniques eff…

Easy
1492

The kth Factor of n

Find the kth factor of n by scanning divisors carefully or using factor pairs to skip unnecessary checks.

Medium
1510

Stone Game IV

Stone Game IV requires predicting the winner using state transition dynamic programming with careful consideration of pe…

Hard
1512

Number of Good Pairs

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

Easy
1513

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…

Medium
1515

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.

Hard
1518

Water Bottles

Maximize the number of water bottles you can drink by simulating the exchange process between full and empty bottles.

Easy
1523

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…

Easy
1524

Number of Sub-arrays With Odd Sum

Count the number of subarrays with an odd sum using dynamic programming and prefix sum techniques.

Medium
1551

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.

Medium
1561

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…

Medium
1563

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…

Hard
1569

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.

Hard
1573

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.

Medium
1577

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

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

Medium
1588

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.

Easy
1610

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…

Hard
1621

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.

Medium
1622

Fancy Sequence

Implement a Fancy sequence supporting append, addAll, and multAll operations efficiently using cumulative math design te…

Hard
1627

Graph Connectivity With Threshold

In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…

Hard
1641

Count Sorted Vowel Strings

Calculate the number of length-n strings with vowels only that are sorted lexicographically using state transitions.

Medium
1643

Kth Smallest Instructions

Find the kth smallest lexicographic instruction sequence for reaching a destination in a grid using state transition dyn…

Hard
1648

Sell Diminishing-Valued Colored Balls

Maximize total value by greedily selling diminishing-valued colored balls based on inventory and customer orders.

Medium
1680

Concatenation of Consecutive Binary Numbers

Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.

Medium
1685

Sum of Absolute Differences in a Sorted Array

Calculate the sum of absolute differences between each element and others in a sorted array efficiently.

Medium
1686

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 …

Medium
1688

Count of Matches in Tournament

Calculate the total matches in a tournament by simulating rounds and applying simple math rules for advancing teams.

Easy
1690

Stone Game VII

Maximize score difference in a two-player turn-based stone removal game using state transition dynamic programming.

Medium
1716

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…

Easy
1728

Cat and Mouse II

Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…

Hard
1735

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…

Hard
1739

Building Boxes

Optimize the number of boxes touching the floor in a cubic room using binary search to minimize floor occupancy.

Hard
1742

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.

Easy
1753

Maximum Score From Removing Stones

Maximize the score in a solitaire game by optimally removing stones from three piles with a greedy approach.

Medium
1759

Count Number of Homogenous Substrings

This problem requires counting all homogenous substrings in a given string and returning the result modulo 10^9 + 7.

Medium
1766

Tree of Coprimes

Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…

Hard
1776

Car Fleet II

Car Fleet II involves calculating collision times between cars traveling at different speeds along a one-lane road using…

Hard
1780

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.

Medium
1799

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 …

Hard
1802

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.

Medium
1806

Minimum Number of Operations to Reinitialize a Permutation

Find the minimum number of operations to reinitialize a permutation of size n using specific operations.

Medium
1808

Maximize Number of Nice Divisors

Solve Maximize Number of Nice Divisors by splitting primeFactors into mostly 3s and using fast modular exponentiation.

Hard
1812

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…

Easy
1814

Count Nice Pairs in an Array

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

Medium
1819

Number of Different Subsequences GCDs

Given an array of positive integers, find the number of different subsequences' GCDs.

Hard
1822

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.

Easy
1823

Find the Winner of the Circular Game

Find the winner of a circular game by simulating the elimination process with a queue-driven approach.

Medium
1828

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…

Medium
1830

Minimum Number of Operations to Make String Sorted

Calculate the minimum operations to sort a string using combinatorial math and string manipulation techniques efficientl…

Hard
1835

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.

Hard
1837

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.

Easy
1840

Maximum Building Height

Find the maximum building height in a city given height restrictions for specific buildings.

Hard
1860

Incremental Memory Leak

Solve Incremental Memory Leak by simulating each second carefully and using math to reason about the crash time bound.

Medium
1862

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…

Hard
1863

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.

Easy
1866

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…

Hard
1872

Stone Game VIII

Stone Game VIII requires calculating maximum score difference using state transition dynamic programming on prefix sums …

Hard
1878

Get Biggest Three Rhombus Sums in a Grid

Find the three largest distinct rhombus sums from a given grid using array and math techniques.

Medium
1884

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…

Medium
1896

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…

Hard
1903

Largest Odd Number in String

Find the largest odd number in a string using a greedy approach with careful digit inspection and invariant checks.

Easy
1904

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…

Medium
1916

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…

Hard
1922

Count Good Numbers

Count Good Numbers uses a mathematical pattern with recursion to efficiently count digit strings of length n under stric…

Medium
1925

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.

Easy
1927

Sum Game

Determine if Alice can force a win in the Sum Game by strategically replacing '?' using a greedy and invariant approach.

Medium
1952

Three Divisors

Determine if a given integer has exactly three positive divisors.

Easy
1954

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…

Medium
1969

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…

Medium
1979

Find Greatest Common Divisor of Array

Find the greatest common divisor of the smallest and largest numbers in an integer array.

Easy
1994

The Number of Good Subsets

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

Hard
1998

GCD Sort of an Array

The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.

Hard
2001

Number of Pairs of Interchangeable Rectangles

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

Medium
2019

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…

Hard
2028

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…

Medium
2029

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…

Medium
2033

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.

Medium
2038

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.

Medium
2048

Next Greater Numerically Balanced Number

Find the smallest numerically balanced number greater than a given integer using backtracking search and pruning.

Medium
2063

Vowels of All Substrings

Compute the total number of vowels in all substrings of a given string using efficient state transition dynamic programm…

Medium
2081

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…

Hard
2101

Detonate the Maximum Bombs

Determine the maximum number of bombs that can be detonated by leveraging chain reactions using graph traversal and DFS …

Medium
2110

Number of Smooth Descent Periods of a Stock

Count all contiguous periods where stock prices descend smoothly by exactly one using dynamic programming techniques.

Medium
2117

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…

Hard
2119

A Number After a Double Reversal

Determine if reversing a number twice returns the original integer by analyzing trailing zeros and digit placement.

Easy
2125

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…

Medium
2139

Minimum Moves to Reach Target Score

Calculate the fewest steps to reach a target integer using increments and limited doubles with a greedy strategy.

Medium
2147

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…

Hard
2160

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.

Easy
2162

Minimum Cost to Set Cooking Time

Calculate the minimum fatigue to set a microwave cooking time using digit moves and pushes efficiently.

Medium
2165

Smallest Value of the Rearranged Number

Rearrange the digits of an integer to minimize its value while avoiding leading zeros, keeping the sign unchanged.

Medium
2169

Count Operations to Obtain Zero

Simulate operations on two integers until one becomes zero, counting how many steps it takes to achieve the result.

Easy
2177

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.

Medium
2178

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…

Medium
2180

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…

Easy
2183

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.

Hard
2195

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.

Medium
2197

Replace Non-Coprime Numbers in Array

Replace Non-Coprime Numbers in Array uses stack-based state management to iteratively merge adjacent non-coprime integer…

Hard
2217

Find Palindrome With Fixed Length

Find the smallest palindromes of a given length for specific queries with mathematical and array manipulation.

Medium
2221

Find Triangular Sum of an Array

The problem asks for calculating the triangular sum of an array through repeated pairwise summation.

Medium
2235

Add Two Integers

This problem asks to return the sum of two integers within a specific range, focusing on math-driven solution strategy.

Easy
2240

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.

Medium
2249

Count Lattice Points Inside a Circle

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

Medium
2266

Count Number of Texts

Calculate the total number of possible original texts from a pressed key sequence using state transition dynamic program…

Medium
2269

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…

Easy
2280

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…

Medium
2310

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.

Medium
2317

Maximum XOR After Operations

Maximize the bitwise XOR of an array after applying a special operation with non-negative integers multiple times.

Medium
2338

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…

Hard
2344

Minimum Deletions to Make Array Divisible

Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.

Hard
2348

Number of Zero-Filled Subarrays

Given an array of integers, count the subarrays that consist entirely of 0s.

Medium
2358

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…

Medium
2364

Count Number of Bad Pairs

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

Medium
2366

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…

Hard
2376

Count Special Integers

Count the number of special integers in the interval [1, n] where digits of each integer are distinct.

Hard
2396

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 …

Medium
2400

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.

Medium
2409

Count Days Spent Together

Count the total number of days Alice and Bob are in Rome together, given their arrival and departure dates.

Easy
2413

Smallest Even Multiple

Find the smallest even multiple of a given integer using math and number theory concepts efficiently.

Easy
2427

Number of Common Factors

The problem asks to find the number of common factors of two positive integers a and b.

Easy
2440

Create Components With Same Value

Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.

Hard
2442

Count Number of Distinct Integers After Reverse Operations

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

Medium
2443

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…

Medium
2447

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.

Medium
2455

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.

Easy
2457

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.

Medium
2469

Convert the Temperature

Convert the given Celsius temperature to Kelvin and Fahrenheit using mathematical formulas and return the result in an a…

Easy
2470

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.

Medium
2481

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…

Easy
2485

Find the Pivot Integer

Find the Pivot Integer problem challenges you to identify an integer x that balances prefix sums on both sides.

Easy
2507

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.

Medium
2513

Minimize the Maximum of Two Arrays

Minimize the Maximum of Two Arrays requires finding the smallest possible maximum number across two arrays, using binary…

Medium
2514

Count Anagrams

Learn to count distinct anagrams for a multi-word string using hash tables, math, and combinatorics efficiently.

Hard
2520

Count the Digits That Divide a Number

Count the digits that divide a number by checking each digit's divisibility.

Easy
2521

Distinct Prime Factors of Product of Array

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

Medium
2523

Closest Prime Numbers in Range

Find the two closest prime numbers within a given range using efficient number theory techniques and gap comparisons.

Medium
2525

Categorize Box According to Criteria

Classify a box as "Heavy", "Bulky", or "Neither" based on its dimensions and mass using math-driven strategies.

Easy
2527

Find Xor-Beauty of Array

Find the xor-beauty of an array by XORing the effective values of all possible triplets of indices.

Medium
2535

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.

Easy
2541

Minimum Operations to Make Array Equal II

Calculate the minimum operations to make two integer arrays equal using greedy adjustments with modular checks efficient…

Medium
2543

Check if Point Is Reachable

Determine if a target point is reachable from (1,1) using math-based moves following number theory rules efficiently.

Hard
2544

Alternating Digit Sum

Compute the alternating digit sum by applying a sign to each digit and summing efficiently using a math-driven approach.

Easy
2549

Count Distinct Numbers on Board

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

Easy
2550

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.

Medium
2566

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…

Easy
2572

Count the Number of Square-Free Subsets

Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…

Medium
2575

Find the Divisibility Array of a String

Calculate the divisibility array for a string by checking if prefixes are divisible by a given number.

Medium
2578

Split With Minimum Sum

Split a positive integer into two parts to minimize their sum using a greedy approach and sorting.

Easy
2579

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 …

Medium
2582

Pass the Pillow

Pass the Pillow simulates the process of passing an item through a line of people, adjusting the direction based on time…

Easy
2584

Split the Array to Make Coprime Products

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

Hard
2591

Distribute Money to Maximum Children

Determine the maximum number of children who can each receive exactly 8 dollars using a greedy approach with validation …

Easy
2597

The Number of Beautiful Subsets

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

Medium
2598

Smallest Missing Non-negative Integer After Operations

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

Medium
2600

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…

Easy
2601

Prime Subtraction Operation

Determine if it's possible to make the array strictly increasing using prime subtractions.

Medium
2607

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.

Medium
2614

Prime In Diagonal

Find the largest prime number located on any diagonal of a square matrix using array iteration and prime checking techni…

Easy
2651

Calculate Delayed Arrival Time

Calculate the new arrival time of a delayed train in 24-hour format by using basic math operations.

Easy
2652

Sum Multiples

Find the sum of integers divisible by 3, 5, or 7 in the range [1, n].

Easy
2654

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…

Medium
2681

Power of Heroes

Calculate the total power of all non-empty hero groups using state transition dynamic programming efficiently with sorti…

Hard
2698

Find the Punishment Number of an Integer

Find the punishment number of a given integer using backtracking search with pruning.

Medium
2709

Greatest Common Divisor Traversal

Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.

Hard
2719

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…

Hard
2729

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…

Easy
2739

Total Distance Traveled

Calculate the maximum distance a truck can travel using main and additional fuel tanks with controlled transfers.

Easy
2745

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.

Medium
2748

Number of Beautiful Pairs

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

Easy
2750

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 …

Medium
2761

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.

Medium
2769

Find the Maximum Achievable Number

Determine the largest number achievable by repeatedly applying a simple math operation up to t times efficiently.

Easy
2790

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…

Hard
2806

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…

Easy
2807

Insert Greatest Common Divisors in Linked List

The problem involves inserting greatest common divisors between adjacent nodes in a linked list.

Medium
2816

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…

Medium
2818

Apply Operations to Maximize Score

Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.

Hard
2827

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.

Hard
2829

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.

Medium
2834

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.

Medium
2842

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…

Hard
2843

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…

Easy
2844

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.

Medium
2849

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.

Medium
2851

String Transformation

Find how many ways string s can be transformed into string t in exactly k operations using suffix rotations.

Hard
2862

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.

Hard
2864

Maximum Odd Binary Number

Rearrange a binary string to form the largest odd binary number using a greedy approach and least significant bit valida…

Easy
2867

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.

Hard
2894

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…

Easy
2928

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…

Easy
2929

Distribute Candies Among Children II

Determine how to distribute n candies among 3 children without exceeding a limit on individual candies.

Medium
2930

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.

Medium
2939

Maximum Xor Product

Find the maximum value of (a XOR x) * (b XOR x) using greedy bitwise choices and invariant validation.

Medium
2946

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…

Easy
2947

Count Beautiful Substrings I

Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.

Medium
2949

Count Beautiful Substrings II

Count Beautiful Substrings II focuses on finding beautiful substrings with hash tables and number theory techniques.

Hard
2954

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…

Hard
2961

Double Modular Exponentiation

Solve the Double Modular Exponentiation problem by applying array manipulation and modular arithmetic to find good indic…

Medium
2963

Count the Number of Good Partitions

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

Hard
2965

Find Missing and Repeated Values

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

Easy
2967

Minimum Cost to Make Array Equalindromic

Determine the minimum cost to convert an integer array into a palindromic array using allowed element modifications effi…

Medium
2999

Count the Number of Powerful Integers

Count the number of powerful integers in a given range by applying state transition dynamic programming with constraints…

Hard
3001

Minimum Moves to Capture The Queen

Determine the fewest moves to capture the black queen using only white pieces with careful position analysis.

Medium
3012

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.

Medium
3014

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.

Easy
3021

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…

Medium
3024

Type of Triangle

Determine the type of triangle from a three-element array using side sums and equality checks efficiently in constant ti…

Easy
3025

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…

Medium
3027

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…

Hard
3044

Most Frequent Prime

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

Medium
3047

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.

Medium
3079

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…

Easy
3084

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.

Medium
3091

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.

Medium
3099

Harshad Number

Given an integer, determine if it is a Harshad number by checking if it's divisible by the sum of its digits.

Easy
3100

Water Bottles II

Compute the maximum number of water bottles you can drink by simulating exchanges with step-by-step math logic.

Medium
3101

Count Alternating Subarrays

Count all alternating subarrays in a binary array efficiently using array patterns and simple mathematical reasoning.

Medium
3102

Minimize Manhattan Distances

Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.

Hard
3115

Maximum Prime Difference

Calculate the largest index gap between prime numbers in an array using array traversal and number theory insights effic…

Medium
3116

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…

Hard
3128

Right Triangles

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

Medium
3153

Sum of Digit Differences of All Pairs

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

Medium
3154

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…

Hard
3178

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.

Easy
3179

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.

Medium
3190

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.

Easy
3222

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…

Easy
3227

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…

Medium
3232

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.

Easy
3233

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.

Medium
3235

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.

Hard
3250

Find the Count of Monotonic Pairs I

Compute the number of monotonic pairs in an integer array using state transition dynamic programming efficiently.

Hard
3251

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…

Hard
3260

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…

Hard
3264

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…

Easy
3270

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.

Easy
3272

Find the Count of Good Integers

Count good integers by rearranging digits to form k-palindromic numbers, leveraging hash tables and math techniques.

Hard
3274

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 …

Easy
3280

Convert Date to Binary

Convert a given Gregorian date string to its binary format by transforming year, month, and day individually without lea…

Easy
3283

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…

Hard
3289

The Two Sneaky Numbers of Digitville

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

Easy
3296

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.

Medium
3300

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…

Easy
3304

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.

Easy
3307

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…

Hard
3312

Sorted GCD Pair Queries

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

Hard
3317

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.

Hard
3326

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…

Medium
3334

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…

Medium
3335

Total Characters in String After Transformations I

Calculate the total number of characters in a string after repeated transformations using dynamic programming and freque…

Medium
3336

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…

Hard
3337

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…

Hard
3343

Count Number of Balanced Permutations

Determine how many distinct permutations of a digit string are balanced using state transition dynamic programming effic…

Hard
3345

Smallest Divisible Digit Product I

Find the smallest number greater than or equal to n whose digit product is divisible by t.

Easy
3348

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…

Hard
3352

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.

Hard
3360

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…

Easy
3370

Smallest Number With All Set Bits

Find the smallest number greater than or equal to n with all set bits in its binary representation.

Easy
3377

Digit Operations to Make Two Integers Equal

Transform n into m using allowed digit operations without creating primes, applying math and graph strategies efficientl…

Medium
3378

Count Connected Components in LCM Graph

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

Hard
3380

Maximum Area Rectangle With Point Constraints I

Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.

Medium
3382

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…

Hard
3395

Subsequences with a Unique Middle Mode I

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

Hard
3404

Count Special Subsequences

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

Medium
3405

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…

Hard
3411

Maximum Subarray With Equal Products

This problem involves finding the longest subarray where the product equals the LCM multiplied by the GCD, leveraging a …

Easy
3426

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.

Hard
3428

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.

Medium
3430

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…

Hard
3432

Count Partitions with Even Sum Difference

Count the number of partitions with an even sum difference from an array of integers.

Easy
3433

Count Mentions Per User

Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…

Medium
3443

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…

Medium
3444

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…

Hard
3461

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.

Easy
3463

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…

Hard
3468

Find the Number of Copy Arrays

Find the number of possible arrays by leveraging bounds and math in this array-based problem.

Medium
3470

Permutations IV

Find the k-th alternating permutation of numbers 1 to n, ensuring no adjacent numbers share parity, using array and math…

Hard
3492

Maximum Containers on a Ship

Determine the maximum number of containers that can be loaded onto a ship's deck without exceeding weight limits.

Easy
3495

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…

Hard
3505

Minimum Operations to Make Elements Within K Subarrays Equal

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

Hard
3512

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.

Easy
3513

Number of Unique XOR Triplets I

Calculate all unique XOR triplet values in a permutation array using array traversal and bit manipulation techniques eff…

Medium
3514

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…

Medium
3516

Find Closest Person

Determine which of two people reaches a third person first using a simple math-driven distance comparison strategy.

Easy
3518

Smallest Palindromic Rearrangement II

Find the k-th lexicographically smallest palindromic rearrangement of a given palindromic string s.

Hard
3519

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…

Hard
3524

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…

Medium
3525

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…

Hard
3536

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…

Easy
3539

Find Sum of Array Product of Magical Sequences

Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…

Hard
3550

Smallest Index With Digit Sum Equal to Index

Find the smallest index in an array where the sum of the digits equals the index.

Easy
3556

Sum of Largest Prime Substrings

Compute the sum of the three largest unique primes from all substrings using hash table plus math efficiently.

Medium
3558

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…

Medium
3559

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.

Hard
3560

Find Minimum Log Transportation Cost

Calculate the minimum cost to transport two logs using a math-driven strategy considering cutting costs and truck limits…

Easy
3569

Maximize Count of Distinct Primes After Split

Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…

Hard
3574

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 …

Hard
3577

Count the Number of Computer Unlocking Permutations

Calculate the total valid unlocking sequences for computers based on their complexity using array and combinatorics logi…

Medium
3588

Find Maximum Area of a Triangle

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

Medium
3589

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…

Medium
3591

Check if Any Element Has Prime Frequency

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

Easy
3602

Hexadecimal and Hexatrigesimal Conversion

Solve Hexadecimal and Hexatrigesimal Conversion by converting n squared to base 16 and n cubed to base 36, then joining …

Easy
3605

Minimum Stability Factor of Array

The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…

Hard
3609

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.

Hard
3618

Split Array by Prime Indices

Split Array by Prime Indices challenges you to separate elements at prime positions and minimize the absolute sum differ…

Medium
3621

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…

Hard
3622

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.

Easy
3623

Count Number of Trapezoids I

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

Medium
3625

Count Number of Trapezoids II

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

Hard
3630

Partition Array for Maximum XOR and AND

Partition the array into three subsequences to maximize XOR and AND operations with a greedy approach.

Hard

Related Patterns

Math LeetCode Problems: 528 Solutions