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. Define the active state/window.
- 2. Update state while preserving invariants.
- 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
Multiply Strings
Multiply Strings requires simulating integer multiplication using only string operations without direct numeric conversi…
Add Binary
Add Binary involves summing two binary strings and returning the result as a binary string using math and string manipul…
Excel Sheet Column Title
Convert a positive integer to its corresponding Excel column title using base-26 math and string manipulation efficientl…
Excel Sheet Column Number
This problem requires converting an Excel column title into its corresponding column number by applying a math and strin…
Integer to English Words
Convert a given integer to its English words representation using mathematical logic and string manipulation.
Convert a Number to Hexadecimal
Convert a 32-bit integer to its hexadecimal string using math operations and careful string manipulation techniques.
Fizz Buzz
Generate a list from 1 to n replacing multiples of 3 with Fizz, 5 with Buzz, and both with FizzBuzz efficiently.
Add Strings
Given two non-negative integers as strings, sum them and return the result as a string without converting to integers di…
Base 7
Convert any given integer to its base 7 string representation using efficient math and string manipulation techniques.
Complex Number Multiplication
This problem requires multiplying two complex numbers, given in string form, and returning the result in the same format…
Find the Closest Palindrome
Identify the nearest palindrome to a given integer string, handling ties and large numbers efficiently using math and st…
Fraction Addition and Subtraction
Solve fraction addition and subtraction by handling expressions, calculating results, and simplifying fractions to irred…
Solve the Equation
Solve the equation for the variable 'x' and determine its value or state if there is no solution or infinite solutions.
Orderly Queue
Given a string and integer k, rearrange characters to achieve the lexicographically smallest string using limited rotati…
Super Palindromes
Count all super-palindromes in a given numeric range, where each is a palindrome and square of a palindrome.
Equal Rational Numbers
Given two rational numbers as strings with possible repeating decimals, determine if they represent the same number.
Robot Bounded In Circle
Determine if a robot following a repeated instruction sequence stays within a bounded circle using math and string simul…
Greatest Common Divisor of Strings
Find the greatest common divisor string between two strings based on the math and string patterns.
Day of the Year
Calculate the day number of the year based on a given Gregorian calendar date in the format YYYY-MM-DD.
Number of Days Between Two Dates
Calculate the exact number of days between two dates using string parsing and arithmetic logic with consistent accuracy.
Simplified Fractions
Generate simplified fractions between 0 and 1 with denominators up to a given integer n.
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…
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.
Count Number of Homogenous Substrings
This problem requires counting all homogenous substrings in a given string and returning the result modulo 10^9 + 7.
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…
Minimum Number of Operations to Make String Sorted
Calculate the minimum operations to sort a string using combinatorial math and string manipulation techniques efficientl…
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…
Count Days Spent Together
Count the total number of days Alice and Bob are in Rome together, given their arrival and departure dates.
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.
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…
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 …
Convert Date to Binary
Convert a given Gregorian date string to its binary format by transforming year, month, and day individually without lea…
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.
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…
Hexadecimal and Hexatrigesimal Conversion
Solve Hexadecimal and Hexatrigesimal Conversion by converting n squared to base 16 and n cubed to base 36, then joining …