LeetCodechevron_rightmath string

math string Pattern

35 problems

Pattern pages help build reusable solving frames. Identify signals first, then explain state, transition, and edge handling.

Recognition Signals

  • Check if the candidate handles carry propagation correctly in a digit-by-digit simulation.
  • Watch for attempts to convert strings directly to integers, which violates constraints.
  • Do you handle carry properly when adding binary digits?

Solve Flow

  1. 1. Define the active state/window.
  2. 2. Update state while preserving invariants.
  3. 3. Validate with edge-heavy examples.

Common Misses

  • Failing to reverse the input strings before multiplying can misalign digits and produce incorrect results.
  • Ignoring the carry during addition can lead to incorrect results.
  • Forgetting to subtract 1 before modulo leads to incorrect letters for multiples of 26.

Recommended Ladder

#TitleDifficulty
43

Multiply Strings

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

Medium
67

Add Binary

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

Easy
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
273

Integer to English Words

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

Hard
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
504

Base 7

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

Easy
537

Complex Number Multiplication

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

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
592

Fraction Addition and Subtraction

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

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
899

Orderly Queue

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

Hard
906

Super Palindromes

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

Hard
972

Equal Rational Numbers

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

Hard
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
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
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
1447

Simplified Fractions

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

Medium
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
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
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
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
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
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
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
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
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
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
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
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

Related Topics

Math plus String LeetCode Pattern: 35 Solutions