FastPrepRich Text Parser Part 2 (Parse Nested Groups)
Problems/Rich Text Parser Part 2 (Parse Nested Groups)

Rich Text Parser Part 2 (Parse Nested Groups)

Figma logoFigma● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: 2026-07-07 — This set reconstructs a real Figma MLE full-time coding screen shared first-hand by a candidate. All four expected outputs are the interviewer's original assertions character for character, including the double-wrapped [['a', 'b', 'c']] shape, so the judged outputs are a 100% match. FastPrep supplied the surrounding wording and constraints; the complete page is estimated to be a 95% match. A community report submitted on Part 1 of this three-part series records a full-time Figma software engineering phone screen on CoderPad on October 13, 2026.

Special thanks: 🌷 A special thank you to our lovely, amazing frenz for sharing interview sightings for this series on October 13, 2026! (∩˃o˂∩)♡ 🩷

🐝 Hi there! The description you are currently reading is one part of a 3-part Figma interview set. It is highly recommended to read ALL THE PARTS before coding as parts build on top of each other 🐳

  • Rich Text Parser Part 1 (Validate Tokens) 🦔
  • Rich Text Parser Part 2 (Parse Nested Groups) 🐹
  • Rich Text Parser Part 3 (Depth Tokens) 🦚

At Figma, documents are stored as nested structures: a paragraph can contain text runs and nested groups, which can themselves contain more groups. You are working with a small text format that describes structures like this. This set reconstructs a real ~45-minute Figma coding screen, part by part.

Setup. The interview starts from a tokenizer that is already written for you. For example, tokenize("(a,b,c)") returns ["(", "a", "b", "c", ")"]. Notice that commas are separators: the tokenizer drops them, so every token you receive is "(", ")", or a word. On FastPrep the tokenizer's output is handed to you directly as the tokens array.

Part 2. Your validator from Part 1 passed, so the interviewer moves on: implement readRichText(tokens) that parses the token stream into a nested list structure. Every ( … ) group becomes a nested list, every word becomes a string, and items that appear next to each other at the same level are siblings in the same enclosing container.

The input is guaranteed well-formed — checking that was Part 1's job.

Output format. Return the parsed document as a Python-style list string:

  • a group serializes as [ … ] with children joined by a comma and a single space
  • words are wrapped in single quotes
  • the return value is the serialization of the document: the list of all top-level items. A document that consists of one group therefore starts with two brackets, e.g. [['a', 'b', 'c']]

In Python, str(nested_list) produces exactly this format.

Function

readRichText(tokens: String[]) → String

Examples

Example 1

tokens = ["(", "a", "b", "c", ")"]return = "[['a', 'b', 'c']]"

This is tokenize("(a,b,c)"). One group with three words. The document is the list of top-level items, so the single group is wrapped once more: [['a', 'b', 'c']].

Example 2

tokens = ["(", "a", "(", "b", ")", "c", ")"]return = "[['a', ['b'], 'c']]"

This is tokenize("(a,(b),c)"). The inner group becomes a nested list between a and c.

Example 3

tokens = ["(", "a", "b", "c", "(", ")", ")"]return = "[['a', 'b', 'c', []]]"

This is tokenize("(a,b,c())"). c and the empty group are two separate siblings — an empty group serializes as [].

Example 4

tokens = ["(", "(", "(", "a", ")", "b", ")", "c", ")"]return = "[[[['a'], 'b'], 'c']]"

This is tokenize("(((a)b)c)"). A word that follows a closed group is a sibling of that group: b sits beside ['a'], and c beside [['a'], 'b'].

Constraints

  • 0 <= tokens.length <= 5000
  • each token is "(", ")", or a lowercase alphanumeric word with at most 10 characters
  • the token stream is well-formed and nesting depth is at most 50

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 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
  • Parse, Validate, and Repair Markdown FormattingONSITE INTERVIEW · Seen Jun 2024
  • Breadth-First Values of a Binary TreeONSITE INTERVIEW · Seen Oct 2022

Similar questions at other companies

  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Single-Pass S-Expression ParserBaseten · ONSITE INTERVIEWBaseten interview questions
  • Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions
  • Decode StringCompass International Holdings · PHONE SCREENCompass International Holdings interview questions
  • 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
  • Parse Nested HTML into a TreeApple · ONSITE INTERVIEWApple interview questions
  • Calculator with ParenthesesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Lisp Expression ParserAmazon · ONSITE INTERVIEW

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 readRichText(String[] tokens) {
      // write your code here
    }

}
Checking account…