hash math Pattern
19 problems
Pattern pages help build reusable solving frames. Identify signals first, then explain state, transition, and edge handling.
Recognition Signals
- Do you handle subtractive notation like IV and IX correctly?
- Can you explain how your hash table mapping covers all decimal place values?
- Do you understand how the subtraction rule works in Roman numerals?
Solve Flow
- 1. Define the active state/window.
- 2. Update state while preserving invariants.
- 3. Validate with edge-heavy examples.
Common Misses
- Ignoring subtractive combinations, leading to outputs like IIII instead of IV.
- Misunderstanding the subtraction rule, such as treating 'IV' as 'IIII' or incorrectly handling cases like 'IX'.
- Failing to correctly identify the repeating decimal pattern.
Recommended Ladder
Integer to Roman
Convert a given integer to its Roman numeral representation using hash table mapping and decimal place math operations e…
Roman to Integer
Convert a Roman numeral string into an integer using a hash table and mathematical principles to determine value order.
Fraction to Recurring Decimal
Convert a fraction into a decimal, handling repeating decimals with parentheses around the repeating part.
Random Pick Index
Random Pick Index involves selecting a random index of a target number in an array with possible duplicates.
Reconstruct Original Digits from English
This problem asks you to reconstruct digits from an out-of-order English string using hash counting and mathematical ded…
Random Flip Matrix
Design an optimized algorithm to randomly flip an index in a matrix, using hash tables and math for efficient random sel…
Reordered Power of 2
Determine if a number's digits can be rearranged to form a power of two using counting and hash-based checks.
Powerful Integers
Find all integers that can be expressed as x^i + y^j up to a given bound using a Hash Table plus Math approach.
Smallest Integer Divisible by K
Find the length of the smallest positive integer divisible by k that consists only of the digit '1'.
Count Largest Group
Count the number of groups with the largest size by summing digits of numbers from 1 to n using a hash table approach.
Maximum Number of Balls in a Box
The problem asks you to find the box with the maximum number of balls based on the sum of digits of ball numbers.
Count Anagrams
Learn to count distinct anagrams for a multi-word string using hash tables, math, and combinatorics efficiently.
Check if The Number is Fascinating
Determine if a 3-digit number is fascinating by checking if the concatenated result of n, 2*n, and 3*n contains all digi…
Count Beautiful Substrings I
Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.
Count Beautiful Substrings II
Count Beautiful Substrings II focuses on finding beautiful substrings with hash tables and number theory techniques.
Find the Count of Good Integers
Count good integers by rearranging digits to form k-palindromic numbers, leveraging hash tables and math techniques.
Maximum Manhattan Distance After K Changes
Solve Maximum Manhattan Distance After K Changes by scanning prefixes and testing the four diagonal target pairs with li…
Smallest Palindromic Rearrangement II
Find the k-th lexicographically smallest palindromic rearrangement of a given palindromic string s.
Sum of Largest Prime Substrings
Compute the sum of the three largest unique primes from all substrings using hash table plus math efficiently.