Math | LeetCode Problems

404 Math solutions to LeetCode solutions.

Math Problems View all solutions →

Add Two Numbers

#2 Medium

Reverse Integer

#7 Easy

Palindrome Number

#9 Easy

Integer to Roman

#12 Medium

Roman to Integer

#13 Easy

Divide Two Integers

#29 Medium

Multiply Strings

#43 Medium

Rotate Image

#48 Medium

Pow(x, n)

#50 Medium

Permutation Sequence

#60 Hard

Unique Paths

#62 Medium

Plus One

#66 Easy

Add Binary

#67 Easy

Sqrt(x)

#69 Medium

Climbing Stairs

#70 Easy

Gray Code

#89 Medium

Unique Binary Search Trees

#96 Medium

Max Points on a Line

#149 Hard

Evaluate Reverse Polish Notation

#150 Medium

Fraction to Recurring Decimal

#166 Medium

Excel Sheet Column Title

#168 Easy

Excel Sheet Column Number

#171 Easy

Factorial Trailing Zeroes

#172 Medium

Rotate Array

#189 Medium

Happy Number

#202 Easy

Count Primes

#204 Medium

Rectangle Area

#223 Medium

Basic Calculator

#224 Hard

Basic Calculator II

#227 Medium

Power of Two

#231 Easy

Number of Digit One

#233 Hard

Different Ways to Add Parentheses

#241 Medium

Add Digits

#258 Easy

Ugly Number

#263 Easy

Ugly Number II

#264 Medium

Missing Number

#268 Easy

Integer to English Words

#273 Hard

Perfect Squares

#279 Medium

Expression Add Operators

#282 Hard

Nim Game

#292 Easy

Super Ugly Number

#313 Medium

Bulb Switcher

#319 Medium

Power of Three

#326 Easy

Self Crossing

#335 Hard

Power of Four

#342 Easy

Integer Break

#343 Medium

Count Numbers with Unique Digits

#357 Medium

Water and Jug Problem

#365 Medium

Valid Perfect Square

#367 Easy

Largest Divisible Subset

#368 Medium

Sum of Two Integers

#371 Medium

Super Pow

#372 Medium

Guess Number Higher or Lower II

#375 Medium

Insert Delete GetRandom O(1)

#380 Medium

Insert Delete GetRandom O(1) - Duplicates allowed

#381 Hard

Linked List Random Node

#382 Medium

Shuffle an Array

#384 Medium

Elimination Game

#390 Medium

Rotate Function

#396 Medium

Random Pick Index

#398 Medium

Nth Digit

#400 Medium

Convert a Number to Hexadecimal

#405 Easy

Fizz Buzz

#412 Easy

Add Strings

#415 Easy

Reconstruct Original Digits from English

#423 Medium

Arranging Coins

#441 Easy

Add Two Numbers II

#445 Medium

Number of Boomerangs

#447 Medium

Minimum Moves to Equal Array Elements

#453 Medium

Poor Pigs

#458 Hard

Minimum Moves to Equal Array Elements II

#462 Medium

Can I Win

#464 Medium

Implement Rand10() Using Rand7()

#470 Medium

Total Hamming Distance

#477 Medium

Generate Random Point in a Circle

#478 Medium

Largest Palindrome Product

#479 Hard

Smallest Good Base

#483 Hard

Predict the Winner

#486 Medium

Construct the Rectangle

#492 Easy

Random Point in Non-overlapping Rectangles

#497 Medium

Base 7

#504 Easy

Perfect Number

#507 Easy

Fibonacci Number

#509 Easy

Random Flip Matrix

#519 Medium

Continuous Subarray Sum

#523 Medium

Random Pick with Weight

#528 Medium

Complex Number Multiplication

#537 Medium

Minimum Time Difference

#539 Medium

Optimal Division

#553 Medium

Next Greater Element III

#556 Medium

Find the Closest Palindrome

#564 Hard

Erect the Fence

#587 Hard

Fraction Addition and Subtraction

#592 Medium

Valid Square

#593 Medium

Range Addition II

#598 Easy

Maximum Product of Three Numbers

#628 Easy

Sum of Square Numbers

#633 Medium

Solve the Equation

#640 Medium

2 Keys Keyboard

#650 Medium

Beautiful Arrangement II

#667 Medium

Kth Smallest Number in Multiplication Table

#668 Hard

Maximum Swap

#670 Medium

Bulb Switcher II

#672 Medium

24 Game

#679 Hard

Random Pick with Blacklist

#710 Hard

Self Dividing Numbers

#728 Easy

Monotone Increasing Digits

#738 Medium

Reach a Number

#754 Medium

Prime Number of Set Bits in Binary Representation

#762 Easy

Basic Calculator IV

#770 Hard

Global and Local Inversions

#775 Medium

K-th Symbol in Grammar

#779 Medium

Reaching Points

#780 Hard

Rabbits in Forest

#781 Medium

Transform to Chessboard

#782 Hard

Rotated Digits

#788 Medium

Escape The Ghosts

#789 Medium

Preimage Size of Factorial Zeroes Function

#793 Hard

Split Array With Same Average

#805 Hard

Soup Servings

#808 Medium

Chalkboard XOR Game

#810 Hard

Largest Triangle Area

#812 Easy

Consecutive Numbers Sum

#829 Hard

Rectangle Overlap

#836 Easy

New 21 Game

#837 Medium

Magic Squares In Grid

#840 Medium

Guess the Word

#843 Hard

Mirror Reflection

#858 Medium

Prime Palindrome

#866 Medium

Reordered Power of 2

#869 Medium

Stone Game

#877 Medium

Nth Magical Number

#878 Hard

Projection Area of 3D Shapes

#883 Easy

Super Egg Drop

#887 Hard

Sum of Subsequence Widths

#891 Hard

Surface Area of 3D Shapes

#892 Easy

Orderly Queue

#899 Hard

Numbers At Most N Given Digit Set

#902 Hard

Super Palindromes

#906 Hard

Smallest Range I

#908 Easy

Smallest Range II

#910 Medium

Cat and Mouse

#913 Hard

X of a Kind in a Deck of Cards

#914 Medium

Number of Music Playlists

#920 Hard

Three Equal Parts

#927 Hard

Beautiful Array

#932 Medium

Minimum Area Rectangle

#939 Medium

Largest Component Size by Common Factor

#952 Hard

Prison Cells After N Days

#957 Medium

Minimum Area Rectangle II

#963 Medium

Least Operators to Express Number

#964 Hard

Powerful Integers

#970 Easy

Equal Rational Numbers

#972 Hard

K Closest Points to Origin

#973 Medium

Largest Perimeter Triangle

#976 Easy

Add to Array-Form of Integer

#989 Easy

Broken Calculator

#991 Medium

Number of Squareful Arrays

#996 Hard

Clumsy Factorial

#1006 Medium

Numbers With Repeated Digits

#1012 Hard

Smallest Integer Divisible by K

#1015 Medium

Convert to Base -2

#1017 Medium

Divisor Game

#1025 Easy

Matrix Cells in Distance Order

#1030 Easy

Moving Stones Until Consecutive

#1033 Medium

Valid Boomerang

#1037 Easy

Moving Stones Until Consecutive II

#1040 Medium

Robot Bounded In Circle

#1041 Medium

Greatest Common Divisor of Strings

#1071 Easy

Adding Two Negabinary Numbers

#1073 Medium

Statistics from a Large Sample

#1093 Medium

Distribute Candies to People

#1103 Easy

Path In Zigzag Labelled Binary Tree

#1104 Medium

Maximum of Absolute Value Expression

#1131 Medium

N-th Tribonacci Number

#1137 Easy

Stone Game II

#1140 Medium

Day of the Year

#1154 Easy

Prime Arrangements

#1175 Easy

Day of the Week

#1185 Easy

Ugly Number III

#1201 Medium

Minimum Cost to Move Chips to The Same Position

#1217 Easy

Airplane Seat Assignment Probability

#1227 Medium

Check If It Is a Straight Line

#1232 Easy

Find Positive Integer Solution for a Given Equation

#1237 Medium

Circular Permutation in Binary Representation

#1238 Medium

Minimum Swaps to Make Strings Equal

#1247 Medium

Count Number of Nice Subarrays

#1248 Medium

Check If It Is a Good Array

#1250 Hard

Cells with Odd Values in a Matrix

#1252 Easy

Minimum Time Visiting All Points

#1266 Easy

Number of Burgers with No Waste of Ingredients

#1276 Medium

Subtract the Product and Sum of Digits of an Integer

#1281 Easy

Convert Binary Number in a Linked List to Integer

#1290 Easy

Find Numbers with Even Number of Digits

#1295 Easy

Find N Unique Integers Sum up to Zero

#1304 Easy

Verbal Arithmetic Puzzle

#1307 Hard

Convert Integer to the Sum of Two No-Zero Integers

#1317 Easy

Maximum 69 Number

#1323 Easy

Reverse Subarray To Maximize Array Value

#1330 Hard

Number of Steps to Reduce a Number to Zero

#1342 Easy

Angle Between Hands of a Clock

#1344 Medium

Product of the Last K Numbers

#1352 Medium

Count All Valid Pickup and Delivery Options

#1359 Hard

Number of Days Between Two Dates

#1360 Easy

Closest Divisors

#1362 Medium

Largest Multiple of Three

#1363 Hard

Four Divisors

#1390 Medium

Count Largest Group

#1399 Easy

Circle and Rectangle Overlapping

#1401 Medium

Stone Game III

#1406 Hard

Find the Minimum Number of Fibonacci Numbers Whose Sum Is K

#1414 Medium

Max Difference You Can Get From Changing an Integer

#1432 Medium

Count Triplets That Can Form Two Arrays of Equal XOR

#1442 Medium

Simplified Fractions

#1447 Medium

Maximum Number of Darts Inside of a Circular Dartboard

#1453 Hard

Probability of a Two Boxes Having The Same Number of Distinct Balls

#1467 Hard

Allocate Mailboxes

#1478 Hard

XOR Operation in an Array

#1486 Easy

The kth Factor of n

#1492 Medium

Stone Game IV

#1510 Hard

Number of Good Pairs

#1512 Easy

Number of Substrings With Only 1s

#1513 Medium

Best Position for a Service Centre

#1515 Hard

Water Bottles

#1518 Easy

Count Odd Numbers in an Interval Range

#1523 Easy

Number of Sub-arrays With Odd Sum

#1524 Medium

Minimum Operations to Make Array Equal

#1551 Medium

Maximum Number of Coins You Can Get

#1561 Medium

Stone Game V

#1563 Hard

Number of Ways to Reorder Array to Get Same BST

#1569 Hard

Number of Ways to Split a String

#1573 Medium

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

#1577 Medium

Sum of All Odd Length Subarrays

#1588 Easy

Maximum Number of Visible Points

#1610 Hard

Number of Sets of K Non-Overlapping Line Segments

#1621 Medium

Fancy Sequence

#1622 Hard

Graph Connectivity With Threshold

#1627 Hard

Count Sorted Vowel Strings

#1641 Medium

Kth Smallest Instructions

#1643 Hard

Sell Diminishing-Valued Colored Balls

#1648 Medium

Concatenation of Consecutive Binary Numbers

#1680 Medium

Sum of Absolute Differences in a Sorted Array

#1685 Medium

Stone Game VI

#1686 Medium

Count of Matches in Tournament

#1688 Easy

Stone Game VII

#1690 Medium

Calculate Money in Leetcode Bank

#1716 Easy

Cat and Mouse II

#1728 Hard

Count Ways to Make Array With Product

#1735 Hard

Building Boxes

#1739 Hard

Maximum Number of Balls in a Box

#1742 Easy

Maximum Score From Removing Stones

#1753 Medium

Count Number of Homogenous Substrings

#1759 Medium

Tree of Coprimes

#1766 Hard

Car Fleet II

#1776 Hard

Check if Number is a Sum of Powers of Three

#1780 Medium

Maximize Score After N Operations

#1799 Hard

Minimum Number of Operations to Reinitialize a Permutation

#1806 Medium

Maximize Number of Nice Divisors

#1808 Hard

Determine Color of a Chessboard Square

#1812 Easy

Count Nice Pairs in an Array

#1814 Medium

Number of Different Subsequences GCDs

#1819 Hard

Sign of the Product of an Array

#1822 Easy

Find the Winner of the Circular Game

#1823 Medium

Queries on Number of Points Inside a Circle

#1828 Medium

Minimum Number of Operations to Make String Sorted

#1830 Hard

Find XOR Sum of All Pairs Bitwise AND

#1835 Hard

Sum of Digits in Base K

#1837 Easy

Maximum Building Height

#1840 Hard

Incremental Memory Leak

#1860 Medium

Sum of Floored Pairs

#1862 Hard

Sum of All Subset XOR Totals

#1863 Easy

Number of Ways to Rearrange Sticks With K Sticks Visible

#1866 Hard

Stone Game VIII

#1872 Hard

Get Biggest Three Rhombus Sums in a Grid

#1878 Medium

Egg Drop With 2 Eggs and N Floors

#1884 Medium

Minimum Cost to Change the Final Value of Expression

#1896 Hard

Largest Odd Number in String

#1903 Easy

The Number of Full Rounds You Have Played

#1904 Medium

Count Ways to Build Rooms in an Ant Colony

#1916 Hard

Count Good Numbers

#1922 Medium

Count Square Sum Triples

#1925 Easy

Sum Game

#1927 Medium

Three Divisors

#1952 Easy

Minimum Garden Perimeter to Collect Enough Apples

#1954 Medium

Minimum Non-Zero Product of the Array Elements

#1969 Medium

Find Greatest Common Divisor of Array

#1979 Easy

The Number of Good Subsets

#1994 Hard

GCD Sort of an Array

#1998 Hard

Number of Pairs of Interchangeable Rectangles

#2001 Medium

The Score of Students Solving Math Expression

#2019 Hard

Find Missing Observations

#2028 Medium

Stone Game IX

#2029 Medium

Minimum Operations to Make a Uni-Value Grid

#2033 Medium

Remove Colored Pieces if Both Neighbors are the Same Color

#2038 Medium

Next Greater Numerically Balanced Number

#2048 Medium

Vowels of All Substrings

#2063 Medium

Sum of k-Mirror Numbers

#2081 Hard

Detonate the Maximum Bombs

#2101 Medium

Number of Smooth Descent Periods of a Stock

#2110 Medium

Abbreviating the Product of a Range

#2117 Hard

A Number After a Double Reversal

#2119 Easy

Number of Laser Beams in a Bank

#2125 Medium

Minimum Moves to Reach Target Score

#2139 Medium

Number of Ways to Divide a Long Corridor

#2147 Hard

Minimum Sum of Four Digit Number After Splitting Digits

#2160 Easy

Minimum Cost to Set Cooking Time

#2162 Medium

Smallest Value of the Rearranged Number

#2165 Medium

Count Operations to Obtain Zero

#2169 Easy

Find Three Consecutive Integers That Sum to a Given Number

#2177 Medium

Maximum Split of Positive Even Integers

#2178 Medium

Count Integers With Even Digit Sum

#2180 Easy

Count Array Pairs Divisible by K

#2183 Hard

Append K Integers With Minimal Sum

#2195 Medium

Replace Non-Coprime Numbers in Array

#2197 Hard

Find Palindrome With Fixed Length

#2217 Medium

Find Triangular Sum of an Array

#2221 Medium

Add Two Integers

#2235 Easy

Number of Ways to Buy Pens and Pencils

#2240 Medium

Count Lattice Points Inside a Circle

#2249 Medium

Count Number of Texts

#2266 Medium

Find the K-Beauty of a Number

#2269 Easy

Minimum Lines to Represent a Line Chart

#2280 Medium

Maximum XOR After Operations

#2317 Medium

Count the Number of Ideal Arrays

#2338 Hard

Number of Zero-Filled Subarrays

#2348 Medium

Maximum Number of Groups Entering a Competition

#2358 Medium

Count Number of Bad Pairs

#2364 Medium

Minimum Replacements to Sort the Array

#2366 Hard

Count Special Integers

#2376 Hard

Strictly Palindromic Number

#2396 Medium

Count Days Spent Together

#2409 Easy

Smallest Even Multiple

#2413 Easy

Number of Common Factors

#2427 Easy

Create Components With Same Value

#2440 Hard

Count Number of Distinct Integers After Reverse Operations

#2442 Medium

Sum of Number and Its Reverse

#2443 Medium

Number of Subarrays With GCD Equal to K

#2447 Medium

Average Value of Even Numbers That Are Divisible by Three

#2455 Easy

Convert the Temperature

#2469 Easy

Number of Subarrays With LCM Equal to K

#2470 Medium

Minimum Cuts to Divide a Circle

#2481 Easy

Find the Pivot Integer

#2485 Easy

Smallest Value After Replacing With Sum of Prime Factors

#2507 Medium

Count the Digits That Divide a Number

#2520 Easy

Distinct Prime Factors of Product of Array

#2521 Medium

Closest Prime Numbers in Range

#2523 Medium

Find Xor-Beauty of Array

#2527 Medium

Difference Between Element Sum and Digit Sum of an Array

#2535 Easy

Check if Point Is Reachable

#2543 Hard

Alternating Digit Sum

#2544 Easy

Count Distinct Numbers on Board

#2549 Easy

Maximum Difference by Remapping a Digit

#2566 Easy

Split With Minimum Sum

#2578 Easy

Count Total Number of Colored Cells

#2579 Medium

Pass the Pillow

#2582 Easy

The Number of Beautiful Subsets

#2597 Medium

Smallest Missing Non-negative Integer After Operations

#2598 Medium

K Items With the Maximum Sum

#2600 Easy

Prime Subtraction Operation

#2601 Medium

Calculate Delayed Arrival Time

#2651 Easy

Sum Multiples

#2652 Easy

Find the Punishment Number of an Integer

#2698 Medium

Greatest Common Divisor Traversal

#2709 Hard

Check if The Number is Fascinating

#2729 Easy

Total Distance Traveled

#2739 Easy

Construct the Longest New String

#2745 Medium

Number of Beautiful Pairs

#2748 Easy

Find the Maximum Achievable Number

#2769 Easy

Account Balance After Rounded Purchase

#2806 Easy

Insert Greatest Common Divisors in Linked List

#2807 Medium

Double a Number Represented as a Linked List

#2816 Medium

Apply Operations to Maximize Score

#2818 Hard

Determine the Minimum Sum of a k-avoiding Array

#2829 Medium

Count Symmetric Integers

#2843 Easy

Maximum Element-Sum of a Complete Subset of Indices

#2862 Hard

Maximum Odd Binary Number

#2864 Easy

Divisible and Non-divisible Sums Difference

#2894 Easy

Distribute Candies Among Children I

#2928 Easy

Distribute Candies Among Children II

#2929 Medium

Matrix Similarity After Cyclic Shifts

#2946 Easy

Count Beautiful Substrings I

#2947 Medium

Double Modular Exponentiation

#2961 Medium

Count the Number of Good Partitions

#2963 Hard

Find Missing and Repeated Values

#2965 Easy

Count the Number of Powerful Integers

#2999 Hard

Minimum Number of Pushes to Type Word I

#3014 Easy

Alice and Bob Playing Flower Game

#3021 Medium

Type of Triangle

#3024 Easy

Find the Number of Ways to Place People I

#3025 Medium

Find the Number of Ways to Place People II

#3027 Hard

Most Frequent Prime

#3044 Medium

Find the Largest Area of Square Inside Two Rectangles

#3047 Medium

Find the Sum of Encrypted Integers

#3079 Easy

Count Substrings Starting and Ending with Given Character

#3084 Medium

Apply Operations to Make Sum of Array Greater Than or Equal to k

#3091 Medium

Harshad Number

#3099 Easy

Water Bottles II

#3100 Medium

Find the Child Who Has the Ball After K Seconds

#3178 Easy

Find the Count of Good Integers

#3272 Hard

Total Characters in String After Transformations I

#3335 Medium

Total Characters in String After Transformations II

#3337 Hard

Count Number of Balanced Permutations

#3343 Hard

Check If Digits Are Equal in String After Operations I

#3461 Easy

Check If Digits Are Equal in String After Operations II

#3463 Hard