LeetCodechevron_rightstring driven

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. 1. Define the active state/window.
  2. 2. Update state while preserving invariants.
  3. 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

#TitleDifficulty
6

Zigzag Conversion

Convert a string into a zigzag pattern across multiple rows and read it line by line efficiently for string manipulation…

Medium
8

String to Integer (atoi)

Convert a string to a 32-bit signed integer by carefully parsing characters, handling signs, and ignoring invalid traili…

Medium
38

Count and Say

Count and Say requires building the nth sequence term by iteratively applying a run-length encoding on strings of digits…

Medium
58

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…

Easy
65

Valid Number

Determine if a given string represents a valid number using precise string parsing and character validation rules.

Hard
434

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.

Easy
468

Validate IP Address

Determine whether a given string is a valid IPv4 or IPv6 address using a precise string-driven validation strategy.

Medium
482

License Key Formatting

Reformat a license key string by splitting into groups of size k, converting to uppercase, and handling dashes appropria…

Easy
520

Detect Capital

Detect Capital asks you to determine if a word follows a correct capital usage pattern based on specific rules.

Easy
521

Longest Uncommon Subsequence I

Determine the length of the longest uncommon subsequence between two strings using a direct string comparison strategy.

Easy
551

Student Attendance Record I

Determine if a student's attendance record qualifies for an award based on specific criteria for absences and lateness.

Easy
709

To Lower Case

The "To Lower Case" problem asks you to convert all uppercase letters in a string to lowercase.

Easy
824

Goat Latin

Convert a sentence to Goat Latin by transforming each word based on vowel rules and incremental suffixes efficiently.

Easy
830

Positions of Large Groups

Identify and return intervals of consecutive, large character groups in a string of lowercase letters.

Easy
831

Masking Personal Information

This problem requires masking sensitive parts of emails and phone numbers using a precise string-driven strategy efficie…

Medium
1078

Occurrences After Bigram

Extract the third word in every adjacent triple of words matching a given bigram pattern from a text.

Easy
1108

Defanging an IP Address

Transform an IPv4 address by replacing each period with '[.]', focusing on a string-driven, direct manipulation approach…

Easy
1309

Decrypt String from Alphabet to Integer Mapping

Decrypt a string using alphabet-to-integer mapping, considering the presence of '#' as a special delimiter.

Easy
1374

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.

Easy
1417

Reformat The String

Reformat The String involves rearranging alphanumeric characters in a string so that no adjacent characters have the sam…

Easy
1446

Consecutive Characters

Find the power of a string by determining the length of its longest substring with a unique character.

Easy
1507

Reformat Date

Reformat Date requires transforming a date string from human-readable form to YYYY-MM-DD using a string-driven strategy …

Easy
1556

Thousand Separator

Convert a given integer into a string with dots as thousand separators using a precise string-driven strategy.

Easy
1576

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.

Easy
1592

Rearrange Spaces Between Words

Rearrange spaces between words by distributing them evenly, placing any leftover spaces at the end to match original tex…

Easy
1678

Goal Parser Interpretation

Interpret the Goal Parser's output by analyzing a command string containing 'G', '()', and '(al)' patterns.

Easy
1694

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…

Easy
1758

Minimum Changes To Make Alternating Binary String

Find the minimum number of changes required to convert a string into an alternating binary string.

Easy
1784

Check if Binary String Has at Most One Segment of Ones

Check if a binary string contains at most one contiguous segment of ones.

Easy
1844

Replace All Digits with Characters

Transform a string by replacing digits at odd indices using the preceding character with a shift operation for accurate …

Easy
1869

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.

Easy
1880

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.

Easy
1957

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…

Easy
2042

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.

Easy
2047

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.

Easy
2124

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…

Easy
2129

Capitalize the Title

Capitalize the Title requires transforming each word based on length, applying uppercase and lowercase rules precisely p…

Easy
2194

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…

Easy
2264

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.

Easy
2278

Percentage of Letter in String

Calculate the percentage of a specific letter in a string using a direct string-driven counting approach, rounding down …

Easy
2288

Apply Discount to Prices

Apply Discount to Prices involves updating a sentence by applying a percentage discount to price words, with precise for…

Medium
2299

Strong Password Checker II

Check if a given password meets all strength requirements, including length, character types, and no adjacent repeated c…

Easy
2315

Count Asterisks

The 'Count Asterisks' problem asks you to count '*' excluding those between pairs of '|' in a string.

Easy
2414

Length of the Longest Alphabetical Continuous Substring

Find the length of the longest continuous alphabetical substring from a given string of lowercase letters.

Medium
2490

Circular Sentence

Determine if a sentence is circular by verifying each word's last character matches the next word's first character effi…

Easy
2609

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.

Easy
2710

Remove Trailing Zeros From a String

Remove trailing zeros from a string representing a positive integer number.

Easy
2839

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.

Easy
2914

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…

Medium
2937

Make Three Strings Equal

Determine the minimum number of operations to make three strings equal by removing rightmost characters from one string …

Easy
3019

Number of Changing Keys

Count how many times a user switches keys in a typed string, ignoring shift and caps lock variations in characters.

Easy
3110

Score of a String

Calculate the sum of absolute ASCII differences between adjacent characters to score any given string efficiently.

Easy
3136

Valid Word

Determine if a given string qualifies as a valid word using a string-driven solution pattern with explicit character rul…

Easy
3163

String Compression III

Compress a string by repeatedly taking maximal same-character prefixes, following a string-driven solution strategy effi…

Medium
3210

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.

Easy
3330

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…

Easy
3340

Check Balanced String

Determine if a numeric string is balanced by comparing sums of digits at even and odd positions efficiently.

Easy
3456

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…

Easy

Related Topics

String-driven solution strategy LeetCode Pattern: 58 Solutions