KatInterview

Topic

Strings interview problems

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

Problems227

60 easy154 medium13 hard

Showing 31–60 of 227 results

  • Encode words as keypad digit strings and answer many digit-prefix queries quickly using sorted ranges or a trie, returning matches in alphabetical order.

    Auto-gradedbinary-searchprefixsortingtrie
  • Count the minimum moves to turn one string into another by moving characters to the front, using a multiset check and a right-to-left greedy subsequence match.

    Auto-gradedstringsgreedytwo-pointerssubsequence
  • Design a robust serialization scheme that packs a list of arbitrary strings into a single string and successfully reconstructs it without ambiguity.

    Auto-gradedstringsarraysdesign-ds
  • Specify precise tokenization rules for counting words in text, then build a Unicode-aware counter that works on huge streams, with tests and a regex versus scanner comparison.

    Model answertokenizationunicodestreamingstate-machine
  • Scan a string left to right, always consuming the longest dictionary word starting at the current position, or one character if none match; tests tries and prefix matching.

    Auto-gradedtriegreedystring-processingprefix-matching
  • Write a single-pass reader for a small Lisp-like syntax with integers, symbols and nested lists, reporting the first error with a clear message and exact character index.

    Model answerparsingrecursive-descenterror-handlings-expression
  • Count every contiguous slice of a lowercase string in which no letter appears twice, using a linear-time sliding window.

    Auto-gradedsliding-windowtwo-pointersstringscounting
  • Aggregate per-host view counts so every host and each of its parent suffixes gets the total of itself and all hosts beneath it, using suffix enumeration and a hash map.

    Auto-gradedhash-mapstringsparsingsuffix-enumeration
  • Simulate telephone keypad multi-tap text encoding while inserting pause delimiters for consecutive letters on the same digit key.

    Auto-gradedstringshash-tablesimulation
  • Check whether a string is a well-formed plain decimal literal (optional sign, digits, optional fraction) by turning a small grammar into a careful single-pass validator.

    Auto-gradedstringsparsingvalidationedge-cases
  • Join byte chunks from a simulated stream and split them into complete messages, using either a 4-byte length prefix or newline delimiters, while ignoring any incomplete tail.

    Auto-gradedbyte-streamparsingframingbuffering
  • Tokenize, validate and evaluate a small Lisp-like language with scoped let bindings, returning None for any malformed or ill-formed input.

    Auto-gradedparsingrecursionscopestring-processing
  • Find the maximum length of a suffix of one string that matches a prefix of another.

    Auto-gradedstringskmpprefix-functiontwo-pointers
  • Combine per-character row strings from a font table into banner lines by joining row i of every glyph in order.

    Auto-gradedstringssimulationhash-mapjoin
  • Parse and compute a non-negative integer arithmetic string with basic binary operators while preserving standard precedence and left-to-right evaluation.

    Auto-gradedstringsparsingstacks-queuesmath-bits
  • Scan candidate codes in order and return the first whose normalized form is within a mismatch limit of a reference, using optional case folding and O/0, I/1 merging.

    Auto-gradedstringshamming-distancenormalizationsimulation
  • Find the longest contiguous substring that reads the same in both directions, returning the leftmost one on ties; tests center expansion or Manacher-style reasoning.

    Auto-gradedstringspalindrometwo-pointersmanacher
  • Count string split points whose halves share more than k distinct characters, and find the most equal-total bundles of one or two items from a cost list, with a special rule for zero-cost items.

    Auto-gradedstringshash-mapcountingprefix-suffix
  • Parse a string of letters with optional multi-digit repeat counts, treating a missing count as one, and rebuild the expanded text in a single left-to-right pass.

    Auto-gradedstring-parsingtwo-pointerssimulationrun-length-encoding
  • Recursively resolve {{dotted.path}} placeholders in a nested request, keeping native types for whole-string matches and stringifying embedded ones.

    Auto-gradedrecursionregexjsontemplate-substitution
  • Decide whether two lowercase strings are rearrangements of each other using letter frequency counting in linear time, without sorting.

    Auto-gradedstringshash-tablefrequency-countanagram
  • Find the fewest moves along a 1D corridor with walls, keys and doors, and notice that the state space collapses to a simple prefix scan.

    Auto-gradedbfsbitmaskstring-scanstate-space
  • Find the maximum length of a contiguous subsequence of string titles containing no duplicated elements using a dynamic sliding window approach.

    Auto-gradedsliding-windowhash-tablestringsarrays
  • Parse a string of numeric digits into all possible valid four-part IPv4 address representations.

    Auto-gradedstringsbacktrackingparsing
  • Tests two linear scans in one function: validating a numeric-skip word abbreviation with two pointers, and checking nested bracket balance with a stack.

    Auto-gradedtwo-pointersstackstring-parsingvalidation
  • Extract case-insensitive ASCII-letter tokens from text, count them, and list the distinct words by descending count with alphabetical tie-breaks.

    Auto-gradedhash-mapstring-parsingsortingfrequency-count
  • Yield data from a continuous stream of string fragments, terminating immediately when a specific multi-character sequence is identified across fragment boundaries.

    Model answerstringssliding-windowtwo-pointerskmp
  • Recall which CSS color function takes red, green and blue channels plus an optional opacity value, and return its canonical name as a string.

    Auto-gradedcssfundamentalstriviastring-return
  • Check whether a shorthand of letters and skip counts exactly describes a word, handling multi-digit counts, leading zeros, overruns and leftover characters with a two-pointer scan.

    Auto-gradedtwo-pointersstring-parsingsimulation
  • Round a decimal string to the nearest integer, then to a power-of-ten step such as 100 or 0.1, using only string and digit operations and a clearly stated tie-breaking rule.

    Model answerstringsroundingbig-numberscarry

More topics