string driven Pattern
58 problems
Pattern pages help build reusable solving frames. Identify signals first, then explain state, transition, and edge handling.
Recognition Signals
- Watch for off-by-one errors in row traversal during zigzag simulation.
- Check whether candidate handles single-row or short strings correctly.
- Clarifies how whitespace and signs are handled before digit accumulation.
Solve Flow
- 1. Define the active state/window.
- 2. Update state while preserving invariants.
- 3. Validate with edge-heavy examples.
Common Misses
- Forgetting to reverse direction when reaching top or bottom row, breaking the zigzag pattern.
- Failing to skip leading spaces before detecting the sign.
- Attempting direct recursion without memoization can lead to stack overflow or repeated work.
Recommended Ladder
Zigzag Conversion
Convert a string into a zigzag pattern across multiple rows and read it line by line efficiently for string manipulation…
String to Integer (atoi)
Convert a string to a 32-bit signed integer by carefully parsing characters, handling signs, and ignoring invalid traili…
Count and Say
Count and Say requires building the nth sequence term by iteratively applying a run-length encoding on strings of digits…
Length of Last Word
Determine the length of the last word in a string using a focused string-driven approach to handle spaces and trailing c…
Valid Number
Determine if a given string represents a valid number using precise string parsing and character validation rules.
Number of Segments in a String
Count the segments of non-space characters in a string by applying a string-driven approach to solve the problem.
Validate IP Address
Determine whether a given string is a valid IPv4 or IPv6 address using a precise string-driven validation strategy.
License Key Formatting
Reformat a license key string by splitting into groups of size k, converting to uppercase, and handling dashes appropria…
Detect Capital
Detect Capital asks you to determine if a word follows a correct capital usage pattern based on specific rules.
Longest Uncommon Subsequence I
Determine the length of the longest uncommon subsequence between two strings using a direct string comparison strategy.
Student Attendance Record I
Determine if a student's attendance record qualifies for an award based on specific criteria for absences and lateness.
To Lower Case
The "To Lower Case" problem asks you to convert all uppercase letters in a string to lowercase.
Goat Latin
Convert a sentence to Goat Latin by transforming each word based on vowel rules and incremental suffixes efficiently.
Positions of Large Groups
Identify and return intervals of consecutive, large character groups in a string of lowercase letters.
Masking Personal Information
This problem requires masking sensitive parts of emails and phone numbers using a precise string-driven strategy efficie…
Occurrences After Bigram
Extract the third word in every adjacent triple of words matching a given bigram pattern from a text.
Defanging an IP Address
Transform an IPv4 address by replacing each period with '[.]', focusing on a string-driven, direct manipulation approach…
Decrypt String from Alphabet to Integer Mapping
Decrypt a string using alphabet-to-integer mapping, considering the presence of '#' as a special delimiter.
Generate a String With Characters That Have Odd Counts
Generate a string of n characters where each character appears an odd number of times, using a string-driven approach.
Reformat The String
Reformat The String involves rearranging alphanumeric characters in a string so that no adjacent characters have the sam…
Consecutive Characters
Find the power of a string by determining the length of its longest substring with a unique character.
Reformat Date
Reformat Date requires transforming a date string from human-readable form to YYYY-MM-DD using a string-driven strategy …
Thousand Separator
Convert a given integer into a string with dots as thousand separators using a precise string-driven strategy.
Replace All ?'s to Avoid Consecutive Repeating Characters
Solve LeetCode 1576 by scanning left to right and replacing each ? with a letter different from its neighbors.
Rearrange Spaces Between Words
Rearrange spaces between words by distributing them evenly, placing any leftover spaces at the end to match original tex…
Goal Parser Interpretation
Interpret the Goal Parser's output by analyzing a command string containing 'G', '()', and '(al)' patterns.
Reformat Phone Number
Reformat a phone number by removing spaces and dashes, grouping digits into blocks of 3 or 2, and joining them with dash…
Minimum Changes To Make Alternating Binary String
Find the minimum number of changes required to convert a string into an alternating binary string.
Check if Binary String Has at Most One Segment of Ones
Check if a binary string contains at most one contiguous segment of ones.
Replace All Digits with Characters
Transform a string by replacing digits at odd indices using the preceding character with a shift operation for accurate …
Longer Contiguous Segments of Ones than Zeros
Determine if the longest segment of 1s in a binary string is strictly longer than the longest segment of 0s.
Check if Word Equals Summation of Two Words
Check if the sum of two word values equals a target word's value by converting letters to their numeric representations.
Delete Characters to Make Fancy String
This problem asks to remove the minimum number of characters from a string to ensure no three consecutive characters are…
Check if Numbers Are Ascending in a Sentence
Check if the numbers in a sentence are strictly increasing from left to right using string tokenization.
Number of Valid Words in a Sentence
Count all valid words in a sentence by analyzing each token with precise string-driven validation rules efficiently.
Check if All A's Appears Before All B's
Determine if all 'a's in a string appear before any 'b's using a direct string-driven check strategy for clarity and cor…
Capitalize the Title
Capitalize the Title requires transforming each word based on length, applying uppercase and lowercase rules precisely p…
Cells in a Range on an Excel Sheet
This problem requires extracting a range of cells from an Excel-like sheet based on a string input and returning them in…
Largest 3-Same-Digit Number in String
Find the largest 3-same-digit number within a string of digits using a string-driven solution approach.
Percentage of Letter in String
Calculate the percentage of a specific letter in a string using a direct string-driven counting approach, rounding down …
Apply Discount to Prices
Apply Discount to Prices involves updating a sentence by applying a percentage discount to price words, with precise for…
Strong Password Checker II
Check if a given password meets all strength requirements, including length, character types, and no adjacent repeated c…
Count Asterisks
The 'Count Asterisks' problem asks you to count '*' excluding those between pairs of '|' in a string.
Length of the Longest Alphabetical Continuous Substring
Find the length of the longest continuous alphabetical substring from a given string of lowercase letters.
Circular Sentence
Determine if a sentence is circular by verifying each word's last character matches the next word's first character effi…
Find the Longest Balanced Substring of a Binary String
Find the longest balanced substring of a binary string where zeroes precede ones and counts of each are equal.
Remove Trailing Zeros From a String
Remove trailing zeros from a string representing a positive integer number.
Check if Strings Can be Made Equal With Operations I
Determine if two strings can be made equal by repeatedly swapping characters at any two indices in each string.
Minimum Number of Changes to Make Binary String Beautiful
This problem involves determining the minimum number of changes to make a binary string beautiful using string-driven st…
Make Three Strings Equal
Determine the minimum number of operations to make three strings equal by removing rightmost characters from one string …
Number of Changing Keys
Count how many times a user switches keys in a typed string, ignoring shift and caps lock variations in characters.
Score of a String
Calculate the sum of absolute ASCII differences between adjacent characters to score any given string efficiently.
Valid Word
Determine if a given string qualifies as a valid word using a string-driven solution pattern with explicit character rul…
String Compression III
Compress a string by repeatedly taking maximal same-character prefixes, following a string-driven solution strategy effi…
Find the Encrypted String
In this problem, you need to encrypt a string by shifting each character's position based on a given integer value.
Find the Original Typed String I
Determine the length of the original string Alice intended to type by analyzing repeated characters and clumsy key press…
Check Balanced String
Determine if a numeric string is balanced by comparing sums of digits at even and odd positions efficiently.
Find Special Substring of Length K
Check efficiently if a string contains a consecutive sequence of length k where all characters match exactly one distinc…