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 1–30 of 227 results

  • Find the lexicographically greatest suffix of a long lowercase string in linear time by comparing candidate start positions without copying and skipping eliminated blocks.

    Auto-gradedstringstwo-pointersgreedysuffix
  • Scan a list of 0/1/? templates, keep those that fit a bit string, and return the one with the fewest wildcards, breaking ties by earliest position.

    Auto-gradedstringspattern-matchinglinear-scantie-breaking
  • Parse a URL query string by hand, then greedily wrap the text to a width and fix a lone last-line word by borrowing from the previous line.

    Auto-gradedstring-parsinggreedysimulationtext-wrapping
  • Find the length of the longest contiguous stretch of a string using no more than k different characters, testing the sliding-window technique with a frequency map.

    Auto-gradedsliding-windowtwo-pointershash-mapstrings
  • Determine whether a given string can be converted into a palindrome by removing no more than one character.

    Auto-gradedstringstwo-pointers
  • Parse an English number phrase (up to millions, optional "negative" prefix) into its integer value using a single left-to-right pass with group accumulators.

    Auto-gradedstring-parsingtokenizationhash-mapsimulation
  • Validate access-log lines field by field, then count client errors, server errors, invalid lines and the failure percentage over the valid lines only.

    Auto-gradedstringsparsingvalidationsimulation
  • Count letter frequencies in two equal-length strings to find the fewest in-place letter replacements that make the second string an anagram of the first.

    Auto-gradedstringshash-mapfrequency-countinganagram
  • Check whether a string is a palindrome when only letters and digits count and case is ignored, using two pointers with constant extra space.

    Auto-gradedtwo-pointersstringspalindrome
  • Compute, for each word, the shortest leading substring shared with no other entry, using prefix counting or a trie, and return the whole word when none exists.

    Auto-gradedtrieprefixhash-mapstrings
  • Build a small browser widget that scores a typed guess of up to five letters against a fixed secret word, marking each letter exact, misplaced or absent, with sound input handling.

    Model answerstringsfrontendstate-managementinput-validation
  • Find all dictionary words that fit a key trace as a start- and end-anchored subsequence where letters may reuse a key, using a next-occurrence table to match many words efficiently.

    Auto-gradedstringssubsequencegreedyprecomputation
  • Expand %NAME% placeholders whose values may reference other placeholders, handling %% escapes, missing names, and circular references.

    Auto-gradedparsingdfsmemoizationcycle-detection
  • Describe how a string is laid out in memory, what copying and moving really cost, what a Rust move does, and how OS threads differ from async coroutines.

    Model answerstringsmemory-managementmove-semanticsrust
  • Find the first second at which at least m substrings of a string contain a corrupted character, using complement counting and a reverse-time merge of clean runs.

    Auto-gradedstringsunion-findcountingreverse-simulation
  • Find the shortest contiguous piece of a text that includes all letters of a target, with repeats and case mattering, using a sliding window with counts and earliest-start tie-breaking.

    Auto-gradedsliding-windowtwo-pointershash-mapstrings
  • Count how often each character occurs in a string and report the tallies in the order the characters first appear, treating every character as distinct and significant.

    Auto-gradedhash-mapstringcountingordered-dict
  • Convert clock strings to minutes and find the shortest wrap-around gap back to a past departure, covering unsorted input, duplicates and an empty schedule.

    Auto-gradedtime-parsingmodular-arithmeticwrap-aroundlinear-scan
  • Tests a sliding window with last-seen indices plus a frequency count to find the longest repeat-free substring and the earliest character occurring exactly once.

    Auto-gradedsliding-windowhash-mapstringsfrequency-count
  • Determine whether an initial 1D board configuration can reach a target configuration based on specific movement and jump rules.

    Model answerstringstwo-pointersinvariants
  • Explain how JavaScript's two equality operators work, how implicit type coercion drives loose equality, where results diverge, and which operator to prefer.

    Model answerjavascripttype-coercionequalitylanguage-fundamentals
  • Determine which words from a dictionary can yield a target string by expanding consecutive duplicate characters in place.

    Auto-gradedstringstwo-pointersarrays
  • Find, for each string, its shortest substring that occurs in no other string (case-insensitive), with leftmost tie-break, and wrap it in brackets while keeping original casing.

    Auto-gradedstringshash-mapsubstringsbitmask
  • Find the longest contiguous segment of a string that reads identically in both directions, preferring the leftmost one on ties and returning an empty string for empty input.

    Auto-gradedstringspalindromeexpand-around-centertwo-pointers
  • Find the length of the longest contiguous block of a string with no repeated character, using a linear-time sliding window with exact, case-sensitive comparison.

    Auto-gradedsliding-windowhash-maptwo-pointersstrings
  • Count substrings of a binary string made of one block of equal characters followed by a block of the other character, with both blocks the same length.

    Auto-gradedstringstwo-pointersrun-lengthcounting
  • Find the longest contiguous stretch of a string containing at most two different characters, testing the sliding window technique with a frequency map.

    Auto-gradedsliding-windowhash-maptwo-pointersstrings
  • Determine the longest initial substring shared across every word in a given list.

    Auto-gradedstringsarraysprefix
  • Filter strings by a character and length rule, an issuer-prefix range and the Luhn checksum, returning the original text of each valid entry in input order.

    Auto-gradedstringsvalidationluhnsimulation
  • Round a decimal number given as a string to the nearest integer, then to its last significant digit, using digit-level arithmetic and carry handling instead of floating-point types.

    Model answerstringscarry-propagationroundingparsing

More topics