Topic
Strings interview problems
Parsing, matching, palindromes and string transforms. 228 original problems, each with hidden test cases you can run in the browser.
60 easy155 medium13 hard
Showing 91–120 of 228 results
Check that every contiguous substring of length at least 3 appears in a word list, testing set-based lookups, loop bounds and the vacuous case for short strings.
Auto-gradedstringshash-setsubstringsenumerationBuild the first n rows of Pascal's triangle and render them as a centered text pyramid with fixed-width, right-aligned cells and floor-based indentation.
Auto-gradedpascal-trianglestring-formattingsimulationmathGreedily pack words into lines of a fixed width, then pad each line with spaces so it is exactly that wide, handling single-word and final lines separately.
Auto-gradedstringsgreedysimulationtext-justificationScan a string once to decide if it matches a small decimal-literal grammar with optional sign, a dotted mantissa and an optional exponent, handling many edge cases.
Auto-gradedstring-parsingstate-machinevalidationedge-casesGreedily word-wrap each paragraph to its own width, then frame all resulting lines in one padded ASCII box sized by the widest paragraph limit.
Auto-gradedstringssimulationgreedytext-formattingScan a word list and drop each word that is a letter rearrangement of the previously kept word, testing signature comparison and order-preserving single-pass filtering.
Auto-gradedstringsanagramssimulationtwo-pointersFilter a word list down to the words whose letters, read through a phone keypad, spell out a given digit string, in original order.
Auto-gradedstringshash-mapfilteringsimulationEvaluate a no-parentheses arithmetic string with correct precedence and truncating division in one pass, using only a few scalar variables instead of a stack.
Auto-gradedstring-parsingtwo-pointerssimulationconstant-spaceFor each query digit string, find the shortest prefix of a digit string containing enough of each digit to form it, using per-digit occurrence lists and a max over digits.
Auto-gradedstringshashingcountingprecomputationParse a valid Roman numeral string into its integer value by handling additive symbols and the six subtractive pairs.
Auto-gradedstringshash-mapparsingsimulationA three-part coding set: bucket words by letter makeup, maximize a number with at most one digit swap, and rank hotels by keyword-based review sentiment.
Model answerhash-mapanagramsgreedytokenizationEncode each maximal run of equal letters as the letter plus its decimal count, and fall back to the input when the encoding is not strictly shorter.
Auto-gradedstringstwo-pointersrun-length-encodingsimulationValidate a strict 8-digit hex string with an optional 0x prefix and convert it into dotted-decimal IPv4 form, treating the leftmost byte as the first octet.
Auto-gradedstringsparsingvalidationhexadecimalDetect which of six SQL clauses appear in a query string and return them in SQL-92 logical evaluation order, using case-insensitive whole-word matching.
Auto-gradedstringsregexsqlparsingFind the earliest-starting match among several keywords, prefer the longest at that spot, and collapse it into a single placeholder character.
Auto-gradedstringsstring-matchingsimulationtrieDesign a stateful tokenizer that turns arbitrarily chunked Markdown into text and code-block events, correctly handling fences split across chunk boundaries.
Model answerstreamingstate-machinestring-parsingmarkdownGiven distinct lowercase words, list every ordered index pair whose concatenation is a palindrome, doing much better than checking all pairs.
Model answerpalindrometriehashingkmpFind the minimum number of source substrings whose concatenation equals the target, using longest-match-per-position and a greedy jump pass.
Auto-gradedstringsgreedysuffix-automatontwo-pointersDecide whether a list of tokens contains a block of a given length repeated a given number of times in a row, testing period detection with a linear scan.
Auto-gradedstringsarrayssliding-windowperiodicityTests depth-first backtracking over operator choices, on-the-fly evaluation without re-parsing, and deterministic tie-breaking when several valid answers exist.
Auto-gradedbacktrackingdfsrecursionstring-constructionWrite and explain a Bash script that creates or reuses a Python virtual environment and installs dependencies, covering strict mode, idempotency, activation pitfalls, and resulting files.
Model answerbashshell-scriptingpython-venvautomationPick words and order them to form the longest string with no repeated character, breaking ties by smallest lexicographic order; tests subset backtracking with disjoint-set pruning.
Auto-gradedbacktrackingsubsetsstringsbitmaskFind the earliest starting index of a pattern inside a text in linear time, handling empty inputs and repetitive patterns, using a prefix-function (KMP-style) scan.
Auto-gradedstringskmptwo-pointerspattern-matchingSplit a line on spaces and count the tokens made only of ASCII letters and the marks , . ? !, testing exact tokenization and character-class checks.
Auto-gradedstringsparsingtokenizationhash-setDiagnose three failures in a small Python template-to-source compiler: a lost ternary branch, a directory returned as a template, and a comment-only loop body, then fix each and add a regression test.
Model answerdebuggingcode-generationastregression-testingFind the minimum character edits so a string becomes both a palindrome and a repetition of a length-k block, by grouping positions into forced-equal classes.
Auto-gradedstringspalindromeperiodicityequivalence-classesFilter support tickets by tab, then by a case-insensitive substring match on title or assignee, handling blank queries and unassigned tickets.
Auto-gradedstringsfilteringcase-insensitivesimulationDiagnose and fix three failing JUnit tests in a Java rewards service by touching at most three files, then explain how to keep similar bugs from coming back.
Model answerjavadebuggingunit-testingjunitFind the longest block of identical letters obtainable by rewriting at most k characters, testing sliding-window reasoning on majority counts for strings up to 100,000 characters.
Auto-gradedsliding-windowstringstwo-pointershashingRebuild a string by alternately picking characters from opposite ends until all are consumed, testing two-pointer convergence logic.
Auto-gradedtwo-pointersstring-manipulationarray