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 61–90 of 228 results

  • 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
  • Find the position of the earliest character that occurs exactly once in a string, with a flag that switches between case-sensitive and case-insensitive matching.

    Auto-gradedstringshash-mapcountingcase-folding
  • Enumerate all well-formed bracket sequences using n pairs, returned in dictionary order, testing pruned backtracking and reasoning about output ordering.

    Auto-gradedbacktrackingrecursioncombinatoricsstrings
  • Write a strict recursive-descent parser that turns JSON text into Python values and raises ValueError on any malformed input.

    Auto-gradedparsingrecursive-descentstringsrecursion
  • Scan a bracketed string of non-negative integers and sum each integer times its bracket nesting level, handling multi-digit numbers, whitespace and empty lists.

    Auto-gradedstring-parsingnested-structuressingle-passbracket-depth
  • Compute the minimum number of adjacent character swaps needed to rearrange a lowercase string into a palindrome, or report -1 if no palindrome is possible.

    Auto-gradedgreedytwo-pointersstringspalindrome
  • Given a word list and a string of keypad digits, return the sorted words whose letters map to exactly that digit sequence, testing string encoding and filtering.

    Auto-gradedstringshashingsortingsimulation
  • Analyze a poorly designed Java method for generating CSV strings and detail performance, RFC 4180 compliance, memory usage, and security enhancements.

    Model answercode-reviewjavastringscsv
  • Locate the index of the earliest symbol in an alphanumeric string that occurs only once, using frequency counting and an ordered scan, or return -1.

    Auto-gradedhash-mapcountingstringtwo-pass
  • Simulate a partial deterministic automaton over the letters a and b, handling missing transitions, invalid symbols and empty input, and report acceptance for a batch of query strings.

    Auto-gradedsimulationhash-mapstate-machinestrings
  • Find the longest contiguous substring in which every letter that appears occurs at least k times, using a sliding window or divide and conquer.

    Auto-gradedsliding-windowstringshash-mapdivide-and-conquer
  • Find the length of the longest contiguous run in a string where every character is distinct, using a linear-time sliding window with index tracking.

    Auto-gradedsliding-windowhash-maptwo-pointersstrings
  • Given a target string and a list of words, return every word that becomes the target after swapping at most one pair of characters in that word, keeping input order.

    Model answerstringstwo-pointerscharacter-frequencybuddy-strings
  • Find the longest distinct word in a list that contains a different word from the list as a contiguous substring, with a fixed tie-break and empty-string handling.

    Auto-gradedstringssubstringsortinghash-set
  • Find the total minimum number of character modifications required to prevent any character from repeating 3 or more times consecutively across a collection of strings.

    Auto-gradedstringsgreedy
  • Validate a list of card number strings against length, prefix, digit-only, and Luhn checksum requirements.

    Auto-gradedstringsarrays
  • Build a browser payment card form where the detected card network drives number formatting, length checks and security-code rules, with validation and a submit callback.

    Model answerfrontendform-validationluhninput-formatting
  • Parse a hex color string (6 or 8 characters) into a 32-bit ARGB packed integer, returning a fallback on invalid input.

    Auto-gradedstringsparsingmath-bits
  • Identify words that appear in either of two given text strings, but not in both, using symmetric set difference.

    Model answerstringsarraysset-operations
  • Scan a string once to find the longest streak of adjacent equal characters, keeping separated streaks distinct and using only constant extra memory.

    Auto-gradedstringstwo-pointerslinear-scanstate-tracking
  • Find the maximum product of lengths of two non-overlapping substrings that do not share any characters.

    Auto-gradedstringsmath-bitsarrays
  • Compute exact-position and misplaced letter counts between a guess and a secret using leftover letter counts, with a sentinel for guesses missing from the word list.

    Auto-gradedstringshashingfrequency-countingsimulation
  • Count how many times a target character, or substring, appears in a text under case-sensitive, non-overlapping matching.

    Auto-gradedstringscountingsubstringcase-sensitive
  • Check if a string's characters can form a palindrome, and implement precise addition of non-negative decimal strings without using native floating-point types.

    Model answerstringsmath-bitshash-table
  • Trace three root causes in a minimal template rendering engine—regex greediness, loop parsing, and path traversal—and present targeted fixes with regression tests.

    Model answerdebuggingparsingregexsecurity
  • Determine the length of the shortest contiguous substring that contains a target count of unique lowercase letters using a sliding window technique.

    Auto-gradedsliding-windowstringstwo-pointershash-table
  • Turn a list of parsed payment records into fixed-layout text cards, testing whitespace trimming, exact decimal rounding, and precise string formatting while preserving order.

    Auto-gradedstring-formattingdecimalparsingsimulation
  • Build a string from a signed 64-bit integer, placing a delimiter between each group of three digits from the right, with the minus sign kept in front, using manual digit handling.

    Auto-gradedstringsmathformattingdigit-extraction
  • Scan a string left to right, replacing each %key% token with its mapped value and returning None when a key is missing; tests careful linear string parsing.

    Auto-gradedstringsparsinghash-maptwo-pointers
  • Audit a short Python function that flattens rows into CSV text, list its correctness and performance flaws with triggering inputs, and rewrite it safely and efficiently.

    Model answercode-reviewcsvpythonstring-building

More topics