KatInterview

practice a little every day — you've got this ♡

Strings Interview Problems

Practice 5971 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.

5971
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 91–120 of 228 results

  • StringsMediumAuto-graded
    Every Window of Length Three or More Must Be a Known Word

    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.

    Stringsstringshash-setsubstringsenumeration
  • StringsMediumAuto-graded
    Centered Pascal Pyramid Renderer

    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.

    Stringspascal-trianglestring-formattingsimulationmath
  • StringsMediumAuto-graded
    Even-Width Paragraph Formatter

    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.

    Stringsstringsgreedysimulationtext-justification
  • StringsMediumAuto-graded
    Check Whether a Token Is a Well-Formed Decimal Literal

    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.

    Stringsstring-parsingstate-machinevalidationedge-cases
  • StringsMediumAuto-graded
    Boxed Multi-Width Paragraph Formatter

    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.

    Stringsstringssimulationgreedytext-formatting
  • StringsMediumAuto-graded
    Squash Consecutive Letter-Rearrangement Duplicates

    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.

    Stringsstringsanagramssimulationtwo-pointers
  • StringsEasyAuto-graded
    Keypad Digit Sequence Word Filter

    Filter a word list down to the words whose letters, read through a phone keypad, spell out a given digit string, in original order.

    Stringsstringshash-mapfilteringsimulation
  • StringsMediumAuto-graded
    Left-to-Right Calculator Using Only Scalar State

    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.

    Stringsstring-parsingtwo-pointerssimulationconstant-space
  • StringsMediumAuto-graded
    Fewest Leading Digits Needed to Rearrange Into Each Word

    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.

    Stringsstringshashingcountingprecomputation
  • StringsEasyAuto-graded
    Decode an Ancient Numeral String into a Number

    Parse a valid Roman numeral string into its integer value by handling additive symbols and the six subtractive pairs.

    Stringsstringshash-mapparsingsimulation
  • StringsMediumModel answer
    Three-Part Drill: Anagram Buckets, One-Swap Max, Sentiment Top-K

    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.

    Stringshash-mapanagramsgreedytokenization
  • StringsMediumAuto-graded
    Shrink Repeated Letters into Letter-Count Pairs

    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.

    Stringsstringstwo-pointersrun-length-encodingsimulation
  • StringsMediumAuto-graded
    Decode a Hex String into a Dotted-Quad Network Address

    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.

    Stringsstringsparsingvalidationhexadecimal
  • StringsEasyAuto-graded
    Report SQL Clauses in Conceptual Evaluation Order

    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.

    Stringsstringsregexsqlparsing
  • StringsMediumAuto-graded
    Mask the Leftmost Longest Keyword in a Text

    Find the earliest-starting match among several keywords, prefer the longest at that spot, and collapse it into a single placeholder character.

    Stringsstringsstring-matchingsimulationtrie
  • StringsHardModel answer
    Chunk-Safe Tokenizer for Fenced Code Blocks

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

    Stringsstreamingstate-machinestring-parsingmarkdown
  • StringsHardModel answer
    Ordered Index Pairs Whose Concatenation Reads the Same Backwards

    Given distinct lowercase words, list every ordered index pair whose concatenation is a palindrome, doing much better than checking all pairs.

    Stringspalindrometriehashingkmp
  • StringsMediumAuto-graded
    Fewest Source Slices to Spell a Target

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

    Stringsstringsgreedysuffix-automatontwo-pointers
  • StringsMediumAuto-graded
    Find a Block Repeated Back-to-Back in a Token List

    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.

    Stringsstringsarrayssliding-windowperiodicity
  • StringsMediumAuto-graded
    Build an expression from 1 to 9 that hits a target

    Tests depth-first backtracking over operator choices, on-the-fly evaluation without re-parsing, and deterministic tie-breaking when several valid answers exist.

    Stringsbacktrackingdfsrecursionstring-construction
  • StringsMediumModel answer
    Bootstrapping a Reproducible Python Environment with Bash

    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.

    Stringsbashshell-scriptingpython-venvautomation
  • StringsMediumAuto-graded
    Longest Repeat-Free Concatenation, Lexicographically Smallest

    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.

    Stringsbacktrackingsubsetsstringsbitmask
  • StringsMediumAuto-graded
    Locate the First Occurrence of a Needle in a Haystack

    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.

    Stringsstringskmptwo-pointerspattern-matching
  • StringsEasyAuto-graded
    Tally Clean Tokens in a Space-Delimited Line

    Split a line on spaces and count the tokens made only of ASCII letters and the marks , . ? !, testing exact tokenization and character-class checks.

    Stringsstringsparsingtokenizationhash-set
  • StringsMediumModel answer
    Three Compiler Defects in a Mini Template Engine: Debug and Test

    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.

    Stringsdebuggingcode-generationastregression-testing
  • StringsMediumAuto-graded
    Fewest Edits to a Repeating Palindromic Pattern

    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.

    Stringsstringspalindromeperiodicityequivalence-classes
  • StringsEasyAuto-graded
    Tab-Scoped Ticket Search with Case-Insensitive Matching

    Filter support tickets by tab, then by a case-insensitive substring match on title or assignee, handling blank queries and unassigned tickets.

    Stringsstringsfilteringcase-insensitivesimulation
  • StringsMediumModel answer
    Repair a Rewards Calculator: Three Red Tests in a Java Service

    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.

    Stringsjavadebuggingunit-testingjunit
  • StringsMediumAuto-graded
    Longest Repeated-Letter Block With a Limited Rewrite Budget

    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.

    Stringssliding-windowstringstwo-pointershashing
  • StringsMediumAuto-graded
    Interleave Characters from String Ends

    Rebuild a string by alternately picking characters from opposite ends until all are consumed, testing two-pointer convergence logic.

    Stringstwo-pointersstring-manipulationarray