LeetCodechevron_rightarray string

array string Pattern

49 problems

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

Recognition Signals

  • Do you understand how to handle edge cases like when there is no common prefix?
  • Can you describe the trade-offs between vertical scanning and horizontal scanning?
  • Able to explain space distribution in detail.

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 handle the case where no common prefix exists, returning an empty string instead of a valid result.
  • Incorrectly distributing spaces when the number of spaces doesn't divide evenly.
  • Not using bitwise operations correctly, leading to inefficient comparisons or incorrect results.

Recommended Ladder

#TitleDifficulty
14

Longest Common Prefix

Find the longest common prefix in an array of strings, returning an empty string if none exists.

Easy
68

Text Justification

Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.

Hard
318

Maximum Product of Word Lengths

The problem requires finding the maximum product of lengths of two words from an array, where the words don't share comm…

Medium
722

Remove Comments

Remove comments from a given C++ program source array, handling line and block comments.

Medium
806

Number of Lines To Write String

Calculate how many lines are needed to write a string given individual letter widths, constrained to 100 pixels per line…

Easy
848

Shifting Letters

Given a string and a shift array, shift the first i+1 letters of the string as specified in the array.

Medium
937

Reorder Data in Log Files

Reorder Data in Log Files requires sorting letter-logs lexicographically while keeping digit-logs in original order for …

Medium
944

Delete Columns to Make Sorted

The 'Delete Columns to Make Sorted' problem asks to remove unsorted columns from a string array, ensuring all columns ar…

Easy
990

Satisfiability of Equality Equations

Determine if it's possible to assign values to variables such that all equations are satisfied based on equality and ine…

Medium
1032

Stream of Characters

Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…

Hard
1233

Remove Sub-Folders from the Filesystem

Remove sub-folders in a filesystem by filtering out folders nested inside other folders.

Medium
1324

Print Words Vertically

Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…

Medium
1408

String Matching in an Array

Identify all strings in an array that appear as substrings of other strings, focusing on array and string matching patte…

Easy
1528

Shuffle String

Reorder characters in a string using a given indices array to reconstruct the intended output efficiently and correctly.

Easy
1629

Slowest Key

Determine which key had the longest press duration in a sequence using array indices and string mapping, resolving ties …

Easy
1662

Check If Two String Arrays are Equivalent

Determine if two string arrays form identical strings by concatenating elements in order, handling subtle array-length m…

Easy
1769

Minimum Number of Operations to Move All Balls to Each Box

Solve the problem of finding the minimum operations to move balls to each box using an efficient approach with arrays an…

Medium
1773

Count Items Matching a Rule

Count Items Matching a Rule is an easy problem that tests array and string manipulation with conditions based on specifi…

Easy
1816

Truncate Sentence

Truncate a sentence to contain only the first k words by converting it into an array of words.

Easy
1967

Number of Strings That Appear as Substrings in Word

Count how many strings in an array appear as substrings within a given word by checking each pattern individually.

Easy
1985

Find the Kth Largest Integer in the Array

This problem asks to find the kth largest integer in an array of string numbers, highlighting sorting and string-based c…

Medium
2011

Final Value of Variable After Performing Operations

Compute the final value of X by simulating each string operation in the array sequentially with careful tracking.

Easy
2114

Maximum Number of Words Found in Sentences

Find the maximum number of words in a single sentence from an array of sentences using array and string processing techn…

Easy
2185

Counting Words With a Given Prefix

Count how many words in a list start with a given prefix.

Easy
2213

Longest Substring of One Repeating Character

Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…

Hard
2255

Count Prefixes of a Given String

Count Prefixes of a Given String is a problem that involves finding the number of string prefixes in an array that match…

Easy
2343

Query Kth Smallest Trimmed Number

Solve the Query Kth Smallest Trimmed Number problem by efficiently trimming and sorting strings in an array to answer qu…

Medium
2381

Shifting Letters II

Shift letters in a string using a sequence of range-based forward or backward operations efficiently with prefix sums.

Medium
2391

Minimum Amount of Time to Collect Garbage

This problem asks you to find the minimum amount of time needed to collect all garbage in a city, focusing on array and …

Medium
2416

Sum of Prefix Scores of Strings

The 'Sum of Prefix Scores of Strings' problem involves calculating prefix scores for strings based on their occurrences …

Hard
2446

Determine if Two Events Have Conflict

Compare two same-day time intervals and check whether their inclusive endpoints overlap after converting HH:MM strings i…

Easy
2452

Words Within Two Edits of Dictionary

Identify all words in queries that can match dictionary entries with at most two character changes efficiently using arr…

Medium
2496

Maximum Value of a String in an Array

The problem requires finding the maximum value of alphanumeric strings in an array based on length or numeric value.

Easy
2515

Shortest Distance to Target String in a Circular Array

Find the shortest distance to a target string in a circular array with either left or right movement options.

Easy
2559

Count Vowel Strings in Ranges

Count the number of strings that start and end with a vowel in given ranges within an array of words.

Medium
2586

Count the Number of Vowel Strings in Range

Count the Number of Vowel Strings in Range asks to count vowel strings in a subarray of a given word list.

Easy
2678

Number of Senior Citizens

Determine how many passengers are over 60 years old based on their compressed details in an array of strings.

Easy
2788

Split Strings by Separator

Split Strings by Separator requires iterating through an array of strings and splitting each by a given separator charac…

Easy
2828

Check if a String Is an Acronym of Words

Check if a string can be formed by concatenating the first letters of each word in a given list.

Easy
2942

Find Words Containing Character

Identify all indices of words containing a specific character using array and string traversal techniques efficiently.

Easy
2976

Minimum Cost to Convert String I

This problem asks to calculate the minimum cost to convert a string from source to target using specific character trans…

Medium
3042

Count Prefix and Suffix Pairs I

Count all index pairs where one word is both a prefix and suffix of another, using efficient array and string checks.

Easy
3045

Count Prefix and Suffix Pairs II

Count the number of index pairs in a string array where one word is both a prefix and suffix of another using array and …

Hard
3093

Longest Common Suffix Queries

Find the index of the string in wordsContainer with the longest common suffix for each query efficiently using array and…

Hard
3248

Snake in Matrix

Solve the Snake in Matrix problem by simulating the snake's movement in a grid based on a series of directional commands…

Easy
3361

Shift Distance Between Two Strings

Find the minimum cost of transforming one string into another, considering operations between characters.

Medium
3485

Longest Common Prefix of K Strings After Removal

Find the longest common prefix length of k strings after removing an element in the array.

Hard
3529

Count Cells in Overlapping Horizontal and Vertical Substrings

Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…

Medium
3598

Longest Common Prefix Between Adjacent Strings After Removals

Given an array of strings, find the longest common prefix length between adjacent strings after removals at each index.

Medium

Related Topics

Array plus String LeetCode Pattern: 49 Solutions