Strings interview questions
Practice 28 questions on strings. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
28 questions
- AlgorithmsCoding exercise
Roman to Integer
EASYConvert a Roman numeral string to its integer value, handling subtractive pairs like IV and IX.
15 minAdobe · Amazon · MicrosoftPractice - JavaScriptCoding exercise
String.prototype.padStart
EASYImplement String.prototype.padStart — pad a string to a target length on the left, truncating a multi-char pad.
15 minPractice - JavaScriptCoding exercise
String.prototype.repeat
EASYImplement String.prototype.repeat — join a string n times, throwing RangeError on a negative or infinite count.
15 minPractice - JavaScriptCoding exercise
String.prototype.trim
EASYImplement String.prototype.trim — strip leading and trailing whitespace, including Unicode whitespace, from a string.
15 minPractice - JavaScriptCoding exercise
Base Converter
MEDIUMConvert a number's string representation between any two bases from 2 to 36 — parse the digits in the source base, then re-emit them in the target base.
25 minPremium questionPractice - JavaScriptCoding exercise
BigInt String Arithmetic
MEDIUMAdd and multiply arbitrarily large non-negative integers given as decimal strings, using digit-by-digit schoolbook arithmetic with carries.
25 minPremium questionPractice - JavaScriptCoding exercise
Caesar Cipher / ROT13
MEDIUMShift each letter by a fixed amount with wraparound, preserving case and passing non-letters through — with ROT13 as the self-inverse case.
25 minPremium questionPractice - JavaScriptCoding exercise
Case Converters
MEDIUMConvert any string between camelCase, snake_case, kebab-case, and PascalCase by tokenizing it into words first.
35 minPremium questionPractice - AlgorithmsCoding exercise
Edit Distance
MEDIUMCompute the minimum number of insertions, deletions, and replacements to turn one string into another — the Levenshtein distance via a 2D dynamic-programming table.
25 minPractice - JavaScriptCoding exercise
Excel Column ↔ Number
MEDIUMConvert between Excel column titles and numbers in both directions — A is 1, Z is 26, AA is 27 — the classic bijective base-26 system with no zero digit.
25 minPremium questionPractice - AlgorithmsCoding exercise
Generate Parentheses
MEDIUMGenerate every well-formed combination of n pairs of parentheses by backtracking — add an open bracket while any remain, and a close bracket only while it stays balanced.
25 minPractice - JavaScriptCoding exercise
IPv4 / IPv6 Validate
MEDIUMValidate IPv4 dotted-quad and IPv6 addresses, handling octet ranges, leading zeros, and :: zero-group compression.
25 minPremium questionPractice - AlgorithmsCoding exercise
Longest Repeating Substring After Replacements
MEDIUMImplement a function that finds the longest substring made of one repeated character allowing up to k swaps.
25 minAmazon · Google · MetaPractice - AlgorithmsCoding exercise
Palindrome Partitioning
MEDIUMSplit a string every possible way so that each piece is a palindrome — backtrack over cut positions, extending a piece only while it reads the same both ways.
25 minPractice - AlgorithmsCoding exercise
Phone Letter Combinations
MEDIUMList every letter string a phone number could spell, mapping each digit to its keypad letters and backtracking through the choices.
25 minPractice - JavaScriptCoding exercise
Roman Numerals ↔ Integer
MEDIUMConvert between Roman numerals and integers in both directions, handling subtractive notation like IV, IX, and XL.
25 minPremium questionPractice - JavaScriptCoding exercise
Run-Length Encoding
MEDIUMImplement run-length encoding: compress runs of repeated characters into count+char pairs, and decode them back.
25 minPremium questionPractice - AlgorithmsCoding exercise
Segment Words
MEDIUMImplement a function that decides whether a string can be broken into a sequence of words from a given dictionary.
25 minAmazon · Google · Meta +1Practice - JavaScriptCoding exercise
Semver Compare
MEDIUMParse and compare two semantic version strings — major, minor, patch, and prerelease — returning -1, 0, or 1 with correct prerelease precedence.
25 minPremium questionPractice - JavaScriptCoding exercise
Slugify
MEDIUMTurn a string into a URL-safe slug: lowercase, strip accents, and collapse non-alphanumeric runs into single hyphens.
25 minPremium questionPractice - JavaScriptCoding exercise
String replaceAll / matchAll
MEDIUMImplement replaceAll and matchAll — replace every occurrence of a substring or global pattern, and iterate every match with its capture groups.
35 minPremium questionPractice - JavaScriptCoding exercise
String to Number (parseInt)
MEDIUMReimplement JavaScript's parseInt — skip leading whitespace, read an optional sign and radix prefix, consume valid digits for the base, and stop at the first invalid character.
25 minPremium questionPractice - JavaScriptCoding exercise
Thousands Separator
MEDIUMGroup a number's integer digits with separators — 1234567 to 1,234,567 — handling decimals, negatives, and a custom separator.
25 minPremium questionPractice - AlgorithmsCoding exercise
Trie (Prefix Tree)
MEDIUMImplement a Trie data structure supporting insert, exact word search, and prefix lookup operations.
25 minPractice - JavaScriptCoding exercise
Truncate String
MEDIUMImplement lodash truncate — cut a string to a maximum length, append an ellipsis, and optionally break on the last word boundary before the limit.
25 minPremium questionPractice - JavaScriptCoding exercise
URLSearchParams
MEDIUMImplement a URLSearchParams-style class with get, getAll, append, set, and toString over an encoded query string.
25 minPremium questionPractice - JavaScriptCoding exercise
Integer to English Words
HARDSpell out a non-negative integer in English words — break it into groups of three digits and name each group with its scale word.
40 minPremium questionPractice - AlgorithmsCoding exercise
Wildcard Matching
HARDDecide whether a string matches a pattern containing `?` (any single character) and `*` (any sequence) — a two-dimensional dynamic-programming match over string and pattern.
40 minPremium questionPractice