FastPrepParse, Validate, and Repair Markdown Formatting
Problems/Parse, Validate, and Repair Markdown Formatting

Parse, Validate, and Repair Markdown Formatting

Figma logoFigma● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes step-by-step support for italic, bold, strikethrough, checking, and automatic repair. We chose a fixed repair rule for crossing markers and the tagged-text format that is returned. Our version is about 84% the same as the reported question.

Process a restricted Markdown string with three formatting markers:

  • * for italic text, rendered as [em]...[/em].
  • ** for bold text, rendered as [strong]...[/strong].
  • ~~ for strikethrough text, rendered as [del]...[/del].

Require properly nested formatting. Recognize two-character markers before a single *. A run of *** closes whichever of nested bold and italic formatting is currently on top, then closes the other with the remaining marker. Repair invalid input deterministically:

  1. If the recognized marker matches the top of the open-marker stack, it closes that format.
  2. If the same marker is open deeper in the stack, the current crossing marker is removed.
  3. Otherwise the marker opens a new format.
  4. After the scan, append closing markers for every still-open format from innermost to outermost.

Return three strings: the tagged text rendered from the repaired Markdown, "true" exactly when no marker was removed or appended, and the repaired Markdown.

Function

processMarkdown(text: String) → String[]

Examples

Example 1

text = "I *really* like this"return = ["I [em]really[/em] like this","true","I *really* like this"]

The italic markers are already balanced and properly nested.

Example 2

text = "**Bold and *italic*** plus ~~old~~"return = ["[strong]Bold and [em]italic[/em][/strong] plus [del]old[/del]","true","**Bold and *italic*** plus ~~old~~"]

The italic section is nested inside bold formatting, and the trailing three stars close italic before bold.

Example 3

text = "*one **two* three**"return = ["[em]one [strong]two three[/strong][/em]","false","*one **two three***"]

The crossing italic marker is removed. Bold then closes normally, and the missing outer italic closer is appended.

Constraints

  • 0 <= text.length <= 200000.
  • The input contains no HTML-sensitive characters <, >, or &.
  • Every * and ~ belongs to a recognized marker; literal marker escaping and empty formatted spans are outside this exercise.
  • Under the repair rules, at most the three distinct formatting kinds can be open at once.

More Figma Onsite Interview questions

  • Recursive Display SortPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Rich Text Parser Part 3 (Depth Tokens)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rich Text Parser Part 2 (Parse Nested Groups)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rich Text Parser Part 1 (Validate Tokens)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Table Selection and Color UpdatesPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Sort Documents Left to RightONSITE INTERVIEW · Seen Aug 2026
  • Symmetric Binary TreeONSITE INTERVIEW · Seen Feb 2026
  • Topmost Accessible NodesPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2025
  • Nested Template Variable ExpansionONSITE INTERVIEW · Seen Jun 2024
  • Breadth-First Values of a Binary TreeONSITE INTERVIEW · Seen Oct 2022

Similar questions at other companies

  • Adjacent Pair and Run RemovalWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • Invoice / Payment ReconciliationStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Single-Pass S-Expression ParserBaseten · ONSITE INTERVIEWBaseten interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Flatten a Mixed JSON ListNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Molecular Weight of a Grouped FormulaAgoda · ONSITE INTERVIEWAgoda interview questions
  • Calculate a Token-List ExpressionCollege Vine · ONSITE INTERVIEW
  • Code Editor FoldingJane Street · ONSITE INTERVIEWJane Street interview questions
  • Trace Events from Stable Whole-Stack StatesAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Parse Nested HTML into a TreeApple · ONSITE INTERVIEWApple interview questions

Figma interview experiences

  • Figma interviews · November 2026
  • Figma SWE Intern OA and Final Round: 21 Experiences
  • Figma SWE Intern OA Questions: 25 Experiences
All Figma interview questionsSee Figma hiring insights
Saved
class Solution {
    public String[] processMarkdown(String text) {
        // Write your code here.
    }
}
Checking account…