Math Problems
528 Math LeetCode problems · Solve with AI-powered hints & step-by-step explanations.
Learn the coding interview patterns behind these problems.
Start with these
2 Add Two Numbers Medium7 Reverse Integer Medium9 Palindrome Number Easy13 Roman to Integer Easy48 Rotate Image Medium62 Unique Paths Medium70 Climbing Stairs Easy268 Missing Number Easy371 Sum of Two Integers Medium412 Fizz Buzz Easy1621 Number of Sets of K Non-Overlapping Line Segments Medium3091 Apply Operations to Make Sum of Array Greater Than or Equal to k Medium3348 Smallest Divisible Digit Product II Hard3558 Number of Ways to Assign Edge Weights I Medium3559 Number of Ways to Assign Edge Weights II Hard
All Math problems
2 Add Two Numbers Medium7 Reverse Integer Medium9 Palindrome Number Easy12 Integer to Roman Medium13 Roman to Integer Easy29 Divide Two Integers Medium43 Multiply Strings Medium48 Rotate Image Medium50 Pow(x, n) Medium60 Permutation Sequence Hard62 Unique Paths Medium66 Plus One Easy67 Add Binary Easy69 Sqrt(x) Easy70 Climbing Stairs Easy89 Gray Code Medium96 Unique Binary Search Trees Medium149 Max Points on a Line Hard150 Evaluate Reverse Polish Notation Medium166 Fraction to Recurring Decimal Medium168 Excel Sheet Column Title Easy171 Excel Sheet Column Number Easy172 Factorial Trailing Zeroes Medium189 Rotate Array Medium202 Happy Number Easy204 Count Primes Medium223 Rectangle Area Medium224 Basic Calculator Hard227 Basic Calculator II Medium231 Power of Two Easy233 Number of Digit One Hard241 Different Ways to Add Parentheses Medium258 Add Digits Easy263 Ugly Number Easy264 Ugly Number II Medium268 Missing Number Easy273 Integer to English Words Hard279 Perfect Squares Medium282 Expression Add Operators Hard292 Nim Game Easy313 Super Ugly Number Medium319 Bulb Switcher Medium326 Power of Three Easy335 Self Crossing Hard342 Power of Four Easy343 Integer Break Medium357 Count Numbers with Unique Digits Medium365 Water and Jug Problem Medium367 Valid Perfect Square Easy368 Largest Divisible Subset Medium371 Sum of Two Integers Medium372 Super Pow Medium375 Guess Number Higher or Lower II Medium380 Insert Delete GetRandom O(1) Medium381 Insert Delete GetRandom O(1) - Duplicates allowed Hard382 Linked List Random Node Medium384 Shuffle an Array Medium390 Elimination Game Medium391 Perfect Rectangle Hard396 Rotate Function Medium398 Random Pick Index Medium400 Nth Digit Medium405 Convert a Number to Hexadecimal Easy412 Fizz Buzz Easy415 Add Strings Easy423 Reconstruct Original Digits from English Medium441 Arranging Coins Easy445 Add Two Numbers II Medium447 Number of Boomerangs Medium453 Minimum Moves to Equal Array Elements Medium458 Poor Pigs Hard462 Minimum Moves to Equal Array Elements II Medium464 Can I Win Medium470 Implement Rand10() Using Rand7() Medium477 Total Hamming Distance Medium478 Generate Random Point in a Circle Medium479 Largest Palindrome Product Hard483 Smallest Good Base Hard486 Predict the Winner Medium492 Construct the Rectangle Easy497 Random Point in Non-overlapping Rectangles Medium504 Base 7 Easy507 Perfect Number Easy509 Fibonacci Number Easy519 Random Flip Matrix Medium523 Continuous Subarray Sum Medium528 Random Pick with Weight Medium537 Complex Number Multiplication Medium539 Minimum Time Difference Medium553 Optimal Division Medium556 Next Greater Element III Medium564 Find the Closest Palindrome Hard587 Erect the Fence Hard592 Fraction Addition and Subtraction Medium593 Valid Square Medium598 Range Addition II Easy628 Maximum Product of Three Numbers Easy633 Sum of Square Numbers Medium640 Solve the Equation Medium650 2 Keys Keyboard Medium667 Beautiful Arrangement II Medium668 Kth Smallest Number in Multiplication Table Hard670 Maximum Swap Medium672 Bulb Switcher II Medium679 24 Game Hard710 Random Pick with Blacklist Hard728 Self Dividing Numbers Easy738 Monotone Increasing Digits Medium754 Reach a Number Medium762 Prime Number of Set Bits in Binary Representation Easy770 Basic Calculator IV Hard775 Global and Local Inversions Medium779 K-th Symbol in Grammar Medium780 Reaching Points Hard781 Rabbits in Forest Medium782 Transform to Chessboard Hard788 Rotated Digits Medium789 Escape The Ghosts Medium793 Preimage Size of Factorial Zeroes Function Hard805 Split Array With Same Average Hard808 Soup Servings Medium810 Chalkboard XOR Game Hard812 Largest Triangle Area Easy829 Consecutive Numbers Sum Hard836 Rectangle Overlap Easy837 New 21 Game Medium840 Magic Squares In Grid Medium843 Guess the Word Hard858 Mirror Reflection Medium866 Prime Palindrome Medium869 Reordered Power of 2 Medium877 Stone Game Medium878 Nth Magical Number Hard883 Projection Area of 3D Shapes Easy887 Super Egg Drop Hard891 Sum of Subsequence Widths Hard892 Surface Area of 3D Shapes Easy899 Orderly Queue Hard902 Numbers At Most N Given Digit Set Hard906 Super Palindromes Hard908 Smallest Range I Easy910 Smallest Range II Medium913 Cat and Mouse Hard914 X of a Kind in a Deck of Cards Easy920 Number of Music Playlists Hard927 Three Equal Parts Hard932 Beautiful Array Medium939 Minimum Area Rectangle Medium952 Largest Component Size by Common Factor Hard957 Prison Cells After N Days Medium963 Minimum Area Rectangle II Medium964 Least Operators to Express Number Hard970 Powerful Integers Medium972 Equal Rational Numbers Hard973 K Closest Points to Origin Medium976 Largest Perimeter Triangle Easy989 Add to Array-Form of Integer Easy991 Broken Calculator Medium996 Number of Squareful Arrays Hard1006 Clumsy Factorial Medium1012 Numbers With Repeated Digits Hard1015 Smallest Integer Divisible by K Medium1017 Convert to Base -2 Medium1025 Divisor Game Easy1030 Matrix Cells in Distance Order Easy1033 Moving Stones Until Consecutive Medium1037 Valid Boomerang Easy1040 Moving Stones Until Consecutive II Medium1041 Robot Bounded In Circle Medium1071 Greatest Common Divisor of Strings Easy1073 Adding Two Negabinary Numbers Medium1093 Statistics from a Large Sample Medium1103 Distribute Candies to People Easy1104 Path In Zigzag Labelled Binary Tree Medium1131 Maximum of Absolute Value Expression Medium1137 N-th Tribonacci Number Easy1140 Stone Game II Medium1154 Day of the Year Easy1175 Prime Arrangements Easy1185 Day of the Week Easy1201 Ugly Number III Medium1217 Minimum Cost to Move Chips to The Same Position Easy1227 Airplane Seat Assignment Probability Medium1232 Check If It Is a Straight Line Easy1237 Find Positive Integer Solution for a Given Equation Medium1238 Circular Permutation in Binary Representation Medium1247 Minimum Swaps to Make Strings Equal Medium1248 Count Number of Nice Subarrays Medium1250 Check If It Is a Good Array Hard1252 Cells with Odd Values in a Matrix Easy1266 Minimum Time Visiting All Points Easy1276 Number of Burgers with No Waste of Ingredients Medium1281 Subtract the Product and Sum of Digits of an Integer Easy1290 Convert Binary Number in a Linked List to Integer Easy1295 Find Numbers with Even Number of Digits Easy1304 Find N Unique Integers Sum up to Zero Easy1307 Verbal Arithmetic Puzzle Hard1317 Convert Integer to the Sum of Two No-Zero Integers Easy1323 Maximum 69 Number Easy1330 Reverse Subarray To Maximize Array Value Hard1342 Number of Steps to Reduce a Number to Zero Easy1344 Angle Between Hands of a Clock Medium1352 Product of the Last K Numbers Medium1359 Count All Valid Pickup and Delivery Options Hard1360 Number of Days Between Two Dates Easy1362 Closest Divisors Medium1363 Largest Multiple of Three Hard1390 Four Divisors Medium1399 Count Largest Group Easy1401 Circle and Rectangle Overlapping Medium1406 Stone Game III Hard1414 Find the Minimum Number of Fibonacci Numbers Whose Sum Is K Medium1432 Max Difference You Can Get From Changing an Integer Medium1442 Count Triplets That Can Form Two Arrays of Equal XOR Medium1447 Simplified Fractions Medium1453 Maximum Number of Darts Inside of a Circular Dartboard Hard1467 Probability of a Two Boxes Having The Same Number of Distinct Balls Hard1478 Allocate Mailboxes Hard1486 XOR Operation in an Array Easy1492 The kth Factor of n Medium1510 Stone Game IV Hard1512 Number of Good Pairs Easy1513 Number of Substrings With Only 1s Medium1515 Best Position for a Service Centre Hard1518 Water Bottles Easy1523 Count Odd Numbers in an Interval Range Easy1524 Number of Sub-arrays With Odd Sum Medium1551 Minimum Operations to Make Array Equal Medium1561 Maximum Number of Coins You Can Get Medium1563 Stone Game V Hard1569 Number of Ways to Reorder Array to Get Same BST Hard1573 Number of Ways to Split a String Medium1577 Number of Ways Where Square of Number Is Equal to Product of Two Numbers Medium1588 Sum of All Odd Length Subarrays Easy1610 Maximum Number of Visible Points Hard1621 Number of Sets of K Non-Overlapping Line Segments Medium1622 Fancy Sequence Hard1627 Graph Connectivity With Threshold Hard1641 Count Sorted Vowel Strings Medium1643 Kth Smallest Instructions Hard1648 Sell Diminishing-Valued Colored Balls Medium1680 Concatenation of Consecutive Binary Numbers Medium1685 Sum of Absolute Differences in a Sorted Array Medium1686 Stone Game VI Medium1688 Count of Matches in Tournament Easy1690 Stone Game VII Medium1716 Calculate Money in Leetcode Bank Easy1728 Cat and Mouse II Hard1735 Count Ways to Make Array With Product Hard1739 Building Boxes Hard1742 Maximum Number of Balls in a Box Easy1753 Maximum Score From Removing Stones Medium1759 Count Number of Homogenous Substrings Medium1766 Tree of Coprimes Hard1776 Car Fleet II Hard1780 Check if Number is a Sum of Powers of Three Medium1799 Maximize Score After N Operations Hard1802 Maximum Value at a Given Index in a Bounded Array Medium1806 Minimum Number of Operations to Reinitialize a Permutation Medium1808 Maximize Number of Nice Divisors Hard1812 Determine Color of a Chessboard Square Easy1814 Count Nice Pairs in an Array Medium1819 Number of Different Subsequences GCDs Hard1822 Sign of the Product of an Array Easy1823 Find the Winner of the Circular Game Medium1828 Queries on Number of Points Inside a Circle Medium1830 Minimum Number of Operations to Make String Sorted Hard1835 Find XOR Sum of All Pairs Bitwise AND Hard1837 Sum of Digits in Base K Easy1840 Maximum Building Height Hard1860 Incremental Memory Leak Medium1862 Sum of Floored Pairs Hard1863 Sum of All Subset XOR Totals Easy1866 Number of Ways to Rearrange Sticks With K Sticks Visible Hard1872 Stone Game VIII Hard1878 Get Biggest Three Rhombus Sums in a Grid Medium1884 Egg Drop With 2 Eggs and N Floors Medium1896 Minimum Cost to Change the Final Value of Expression Hard1903 Largest Odd Number in String Easy1904 The Number of Full Rounds You Have Played Medium1916 Count Ways to Build Rooms in an Ant Colony Hard1922 Count Good Numbers Medium1925 Count Square Sum Triples Easy1927 Sum Game Medium1952 Three Divisors Easy1954 Minimum Garden Perimeter to Collect Enough Apples Medium1969 Minimum Non-Zero Product of the Array Elements Medium1979 Find Greatest Common Divisor of Array Easy1994 The Number of Good Subsets Hard1998 GCD Sort of an Array Hard2001 Number of Pairs of Interchangeable Rectangles Medium2019 The Score of Students Solving Math Expression Hard2028 Find Missing Observations Medium2029 Stone Game IX Medium2033 Minimum Operations to Make a Uni-Value Grid Medium2038 Remove Colored Pieces if Both Neighbors are the Same Color Medium2048 Next Greater Numerically Balanced Number Medium2063 Vowels of All Substrings Medium2081 Sum of k-Mirror Numbers Hard2101 Detonate the Maximum Bombs Medium2110 Number of Smooth Descent Periods of a Stock Medium2117 Abbreviating the Product of a Range Hard2119 A Number After a Double Reversal Easy2125 Number of Laser Beams in a Bank Medium2139 Minimum Moves to Reach Target Score Medium2147 Number of Ways to Divide a Long Corridor Hard2160 Minimum Sum of Four Digit Number After Splitting Digits Easy2162 Minimum Cost to Set Cooking Time Medium2165 Smallest Value of the Rearranged Number Medium2169 Count Operations to Obtain Zero Easy2177 Find Three Consecutive Integers That Sum to a Given Number Medium2178 Maximum Split of Positive Even Integers Medium2180 Count Integers With Even Digit Sum Easy2183 Count Array Pairs Divisible by K Hard2195 Append K Integers With Minimal Sum Medium2197 Replace Non-Coprime Numbers in Array Hard2217 Find Palindrome With Fixed Length Medium2221 Find Triangular Sum of an Array Medium2235 Add Two Integers Easy2240 Number of Ways to Buy Pens and Pencils Medium2249 Count Lattice Points Inside a Circle Medium2266 Count Number of Texts Medium2269 Find the K-Beauty of a Number Easy2280 Minimum Lines to Represent a Line Chart Medium2310 Sum of Numbers With Units Digit K Medium2317 Maximum XOR After Operations Medium2338 Count the Number of Ideal Arrays Hard2344 Minimum Deletions to Make Array Divisible Hard2348 Number of Zero-Filled Subarrays Medium2358 Maximum Number of Groups Entering a Competition Medium2364 Count Number of Bad Pairs Medium2366 Minimum Replacements to Sort the Array Hard2376 Count Special Integers Hard2396 Strictly Palindromic Number Medium2400 Number of Ways to Reach a Position After Exactly k Steps Medium2409 Count Days Spent Together Easy2413 Smallest Even Multiple Easy2427 Number of Common Factors Easy2440 Create Components With Same Value Hard2442 Count Number of Distinct Integers After Reverse Operations Medium2443 Sum of Number and Its Reverse Medium2447 Number of Subarrays With GCD Equal to K Medium2455 Average Value of Even Numbers That Are Divisible by Three Easy2457 Minimum Addition to Make Integer Beautiful Medium2469 Convert the Temperature Easy2470 Number of Subarrays With LCM Equal to K Medium2481 Minimum Cuts to Divide a Circle Easy2485 Find the Pivot Integer Easy2507 Smallest Value After Replacing With Sum of Prime Factors Medium2513 Minimize the Maximum of Two Arrays Medium2514 Count Anagrams Hard2520 Count the Digits That Divide a Number Easy2521 Distinct Prime Factors of Product of Array Medium2523 Closest Prime Numbers in Range Medium2525 Categorize Box According to Criteria Easy2527 Find Xor-Beauty of Array Medium2535 Difference Between Element Sum and Digit Sum of an Array Easy2541 Minimum Operations to Make Array Equal II Medium2543 Check if Point Is Reachable Hard2544 Alternating Digit Sum Easy2549 Count Distinct Numbers on Board Easy2550 Count Collisions of Monkeys on a Polygon Medium2566 Maximum Difference by Remapping a Digit Easy2572 Count the Number of Square-Free Subsets Medium2575 Find the Divisibility Array of a String Medium2578 Split With Minimum Sum Easy2579 Count Total Number of Colored Cells Medium2582 Pass the Pillow Easy2584 Split the Array to Make Coprime Products Hard2591 Distribute Money to Maximum Children Easy2597 The Number of Beautiful Subsets Medium2598 Smallest Missing Non-negative Integer After Operations Medium2600 K Items With the Maximum Sum Easy2601 Prime Subtraction Operation Medium2607 Make K-Subarray Sums Equal Medium2614 Prime In Diagonal Easy2651 Calculate Delayed Arrival Time Easy2652 Sum Multiples Easy2654 Minimum Number of Operations to Make All Array Elements Equal to 1 Medium2681 Power of Heroes Hard2698 Find the Punishment Number of an Integer Medium2709 Greatest Common Divisor Traversal Hard2719 Count of Integers Hard2729 Check if The Number is Fascinating Easy2739 Total Distance Traveled Easy2745 Construct the Longest New String Medium2748 Number of Beautiful Pairs Easy2750 Ways to Split Array Into Good Subarrays Medium2761 Prime Pairs With Target Sum Medium2769 Find the Maximum Achievable Number Easy2790 Maximum Number of Groups With Increasing Length Hard2806 Account Balance After Rounded Purchase Easy2807 Insert Greatest Common Divisors in Linked List Medium2816 Double a Number Represented as a Linked List Medium2818 Apply Operations to Maximize Score Hard2827 Number of Beautiful Integers in the Range Hard2829 Determine the Minimum Sum of a k-avoiding Array Medium2834 Find the Minimum Possible Sum of a Beautiful Array Medium2842 Count K-Subsequences of a String With Maximum Beauty Hard2843 Count Symmetric Integers Easy2844 Minimum Operations to Make a Special Number Medium2849 Determine if a Cell Is Reachable at a Given Time Medium2851 String Transformation Hard2862 Maximum Element-Sum of a Complete Subset of Indices Hard2864 Maximum Odd Binary Number Easy2867 Count Valid Paths in a Tree Hard2894 Divisible and Non-divisible Sums Difference Easy2928 Distribute Candies Among Children I Easy2929 Distribute Candies Among Children II Medium2930 Number of Strings Which Can Be Rearranged to Contain Substring Medium2939 Maximum Xor Product Medium2946 Matrix Similarity After Cyclic Shifts Easy2947 Count Beautiful Substrings I Medium2949 Count Beautiful Substrings II Hard2954 Count the Number of Infection Sequences Hard2961 Double Modular Exponentiation Medium2963 Count the Number of Good Partitions Hard2965 Find Missing and Repeated Values Easy2967 Minimum Cost to Make Array Equalindromic Medium2999 Count the Number of Powerful Integers Hard3001 Minimum Moves to Capture The Queen Medium3012 Minimize Length of Array Using Operations Medium3014 Minimum Number of Pushes to Type Word I Easy3021 Alice and Bob Playing Flower Game Medium3024 Type of Triangle Easy3025 Find the Number of Ways to Place People I Medium3027 Find the Number of Ways to Place People II Hard3044 Most Frequent Prime Medium3047 Find the Largest Area of Square Inside Two Rectangles Medium3079 Find the Sum of Encrypted Integers Easy3084 Count Substrings Starting and Ending with Given Character Medium3091 Apply Operations to Make Sum of Array Greater Than or Equal to k Medium3099 Harshad Number Easy3100 Water Bottles II Medium3101 Count Alternating Subarrays Medium3102 Minimize Manhattan Distances Hard3115 Maximum Prime Difference Medium3116 Kth Smallest Amount With Single Denomination Combination Hard3128 Right Triangles Medium3153 Sum of Digit Differences of All Pairs Medium3154 Find Number of Ways to Reach the K-th Stair Hard3178 Find the Child Who Has the Ball After K Seconds Easy3179 Find the N-th Value After K Seconds Medium3190 Find Minimum Operations to Make All Elements Divisible by Three Easy3222 Find the Winning Player in Coin Game Easy3227 Vowels Game in a String Medium3232 Find if Digit Game Can Be Won Easy3233 Find the Count of Numbers Which Are Not Special Medium3235 Check if the Rectangle Corner Is Reachable Hard3250 Find the Count of Monotonic Pairs I Hard3251 Find the Count of Monotonic Pairs II Hard3260 Find the Largest Palindrome Divisible by K Hard3264 Final Array State After K Multiplication Operations I Easy3270 Find the Key of the Numbers Easy3272 Find the Count of Good Integers Hard3274 Check if Two Chessboard Squares Have the Same Color Easy3280 Convert Date to Binary Easy3283 Maximum Number of Moves to Kill All Pawns Hard3289 The Two Sneaky Numbers of Digitville Easy3296 Minimum Number of Seconds to Make Mountain Height Zero Medium3300 Minimum Element After Replacement With Digit Sum Easy3304 Find the K-th Character in String Game I Easy3307 Find the K-th Character in String Game II Hard3312 Sorted GCD Pair Queries Hard3317 Find the Number of Possible Ways for an Event Hard3326 Minimum Division Operations to Make Array Non Decreasing Medium3334 Find the Maximum Factor Score of Array Medium3335 Total Characters in String After Transformations I Medium3336 Find the Number of Subsequences With Equal GCD Hard3337 Total Characters in String After Transformations II Hard3343 Count Number of Balanced Permutations Hard3345 Smallest Divisible Digit Product I Easy3348 Smallest Divisible Digit Product II Hard3352 Count K-Reducible Numbers Less Than N Hard3360 Stone Removal Game Easy3370 Smallest Number With All Set Bits Easy3377 Digit Operations to Make Two Integers Equal Medium3378 Count Connected Components in LCM Graph Hard3380 Maximum Area Rectangle With Point Constraints I Medium3382 Maximum Area Rectangle With Point Constraints II Hard3395 Subsequences with a Unique Middle Mode I Hard3404 Count Special Subsequences Medium3405 Count the Number of Arrays with K Matching Adjacent Elements Hard3411 Maximum Subarray With Equal Products Easy3426 Manhattan Distances of All Arrangements of Pieces Hard3428 Maximum and Minimum Sums of at Most Size K Subsequences Medium3430 Maximum and Minimum Sums of at Most Size K Subarrays Hard3432 Count Partitions with Even Sum Difference Easy3433 Count Mentions Per User Medium3443 Maximum Manhattan Distance After K Changes Medium3444 Minimum Increments for Target Multiples in an Array Hard3461 Check If Digits Are Equal in String After Operations I Easy3463 Check If Digits Are Equal in String After Operations II Hard3468 Find the Number of Copy Arrays Medium3470 Permutations IV Hard3492 Maximum Containers on a Ship Easy3495 Minimum Operations to Make Array Elements Zero Hard3505 Minimum Operations to Make Elements Within K Subarrays Equal Hard3512 Minimum Operations to Make Array Sum Divisible by K Easy3513 Number of Unique XOR Triplets I Medium3514 Number of Unique XOR Triplets II Medium3516 Find Closest Person Easy3518 Smallest Palindromic Rearrangement II Hard3519 Count Numbers with Non-Decreasing Digits Hard3524 Find X Value of Array I Medium3525 Find X Value of Array II Hard3536 Maximum Product of Two Digits Easy3539 Find Sum of Array Product of Magical Sequences Hard3550 Smallest Index With Digit Sum Equal to Index Easy3556 Sum of Largest Prime Substrings Medium3558 Number of Ways to Assign Edge Weights I Medium3559 Number of Ways to Assign Edge Weights II Hard3560 Find Minimum Log Transportation Cost Easy3569 Maximize Count of Distinct Primes After Split Hard3574 Maximize Subarray GCD Score Hard3577 Count the Number of Computer Unlocking Permutations Medium3588 Find Maximum Area of a Triangle Medium3589 Count Prime-Gap Balanced Subarrays Medium3591 Check if Any Element Has Prime Frequency Easy3602 Hexadecimal and Hexatrigesimal Conversion Easy3605 Minimum Stability Factor of Array Hard3609 Minimum Moves to Reach Target in Grid Hard3618 Split Array by Prime Indices Medium3621 Number of Integers With Popcount-Depth Equal to K I Hard3622 Check Divisibility by Digit Sum and Product Easy3623 Count Number of Trapezoids I Medium3625 Count Number of Trapezoids II Hard3630 Partition Array for Maximum XOR and AND Hard