math driven Pattern
43 problems
Pattern pages help build reusable solving frames. Identify signals first, then explain state, transition, and edge handling.
Recognition Signals
- Expect discussion about handling overflow conditions explicitly.
- Clarify whether negative numbers should retain their sign after reversal.
- Checks if you can handle numeric operations without string conversion.
Solve Flow
- 1. Define the active state/window.
- 2. Update state while preserving invariants.
- 3. Validate with edge-heavy examples.
Common Misses
- Failing to check for 32-bit overflow before updating the reversed number.
- Reversing the entire number can cause integer overflow.
- Brute force methods that attempt to calculate n! directly will fail for large values of n due to factorial growth.
Recommended Ladder
Reverse Integer
Reverse Integer challenges you to invert the digits of a signed 32-bit integer, handling overflow and negative values ca…
Palindrome Number
Determine if a given integer reads the same forward and backward using a math-driven solution strategy without convertin…
Factorial Trailing Zeroes
Given a number n, find how many trailing zeroes are in n! using a math-driven approach.
Ugly Number
The Ugly Number problem asks you to determine if a number is divisible only by 2, 3, or 5.
Construct the Rectangle
Given an area, design a rectangle with integer length and width optimizing L >= W and minimal difference, using math.
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.
Self Dividing Numbers
Identify self-dividing numbers in a given range by verifying divisibility against their digits.
Reaching Points
Determine whether it is possible to reach a target point from a start point using repeated additive moves following stri…
Convert to Base -2
Convert any non-negative integer into its base -2 representation using a math-driven iterative remainder strategy.
Prime Arrangements
Calculate the number of valid permutations of 1 to n where prime numbers occupy prime indices using math-driven logic.
Day of the Week
Given a date, calculate the corresponding weekday using a math-based strategy, focusing on modular arithmetic.
Number of Burgers with No Waste of Ingredients
Determine the exact counts of jumbo and small burgers using all tomato and cheese slices without leftovers, applying mat…
Subtract the Product and Sum of Digits of an Integer
Calculate the difference between the product and sum of an integer's digits using a simple math-driven approach for effi…
Convert 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.
Angle Between Hands of a Clock
Calculate the smaller angle between the hour and minute hands of a clock based on given time inputs.
Closest Divisors
Find the closest divisors of num + 1 and num + 2 with minimal absolute difference in this math-driven problem.
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…
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.
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…
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.
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.
Abbreviating the Product of a Range
Calculate the abbreviated product of integers in a range efficiently using math-driven analysis of trailing zeros and si…
A Number After a Double Reversal
Determine if reversing a number twice returns the original integer by analyzing trailing zeros and digit placement.
Add Two Integers
This problem asks to return the sum of two integers within a specific range, focusing on math-driven solution strategy.
Convert the Temperature
Convert the given Celsius temperature to Kelvin and Fahrenheit using mathematical formulas and return the result in an a…
Count the Digits That Divide a Number
Count the digits that divide a number by checking each digit's divisibility.
Categorize Box According to Criteria
Classify a box as "Heavy", "Bulky", or "Neither" based on its dimensions and mass using math-driven strategies.
Alternating Digit Sum
Compute the alternating digit sum by applying a sign to each digit and summing efficiently using a math-driven approach.
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 …
Calculate Delayed Arrival Time
Calculate the new arrival time of a delayed train in 24-hour format by using basic math operations.
Sum Multiples
Find the sum of integers divisible by 3, 5, or 7 in the range [1, n].
Find the Maximum Achievable Number
Determine the largest number achievable by repeatedly applying a simple math operation up to t times efficiently.
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…
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.
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…
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…
Harshad Number
Given an integer, determine if it is a Harshad number by checking if it's divisible by the sum of its digits.
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.
Maximum Containers on a Ship
Determine the maximum number of containers that can be loaded onto a ship's deck without exceeding weight limits.
Find Closest Person
Determine which of two people reaches a third person first using a simple math-driven distance comparison strategy.
Find Minimum Log Transportation Cost
Calculate the minimum cost to transport two logs using a math-driven strategy considering cutting costs and truck limits…
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.
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.