KatInterview

Topic

Strings interview problems

Parsing, matching, palindromes and string transforms. 228 original problems, each with hidden test cases you can run in the browser.

Problems228

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-setsubstringsenumeration
  • Build 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-formattingsimulationmath
  • Greedily 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-justification
  • Scan 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-cases
  • Greedily 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-formatting
  • Scan 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-pointers
  • Filter 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-mapfilteringsimulation
  • Evaluate 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-space
  • For 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-gradedstringshashingcountingprecomputation
  • Parse a valid Roman numeral string into its integer value by handling additive symbols and the six subtractive pairs.

    Auto-gradedstringshash-mapparsingsimulation
  • A 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-mapanagramsgreedytokenization
  • Encode 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-encodingsimulation
  • Validate 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-gradedstringsparsingvalidationhexadecimal
  • Detect 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-gradedstringsregexsqlparsing
  • Find the earliest-starting match among several keywords, prefer the longest at that spot, and collapse it into a single placeholder character.

    Auto-gradedstringsstring-matchingsimulationtrie
  • Design a stateful tokenizer that turns arbitrarily chunked Markdown into text and code-block events, correctly handling fences split across chunk boundaries.

    Model answerstreamingstate-machinestring-parsingmarkdown
  • Given distinct lowercase words, list every ordered index pair whose concatenation is a palindrome, doing much better than checking all pairs.

    Model answerpalindrometriehashingkmp
  • Find the minimum number of source substrings whose concatenation equals the target, using longest-match-per-position and a greedy jump pass.

    Auto-gradedstringsgreedysuffix-automatontwo-pointers
  • Decide 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-windowperiodicity
  • Tests depth-first backtracking over operator choices, on-the-fly evaluation without re-parsing, and deterministic tie-breaking when several valid answers exist.

    Auto-gradedbacktrackingdfsrecursionstring-construction
  • Write 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-venvautomation
  • Pick 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-gradedbacktrackingsubsetsstringsbitmask
  • Find 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-matching
  • Split 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-set
  • Diagnose 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-testing
  • Find 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-classes
  • Filter support tickets by tab, then by a case-insensitive substring match on title or assignee, handling blank queries and unassigned tickets.

    Auto-gradedstringsfilteringcase-insensitivesimulation
  • Diagnose 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-testingjunit
  • Find 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-pointershashing
  • Rebuild a string by alternately picking characters from opposite ends until all are consumed, testing two-pointer convergence logic.

    Auto-gradedtwo-pointersstring-manipulationarray

More topics