FastPrepConvert Email Text to Structured Markup
Problems/Convert Email Text to Structured Markup

Convert Email Text to Structured Markup

Zip logoZip● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reports give the paragraph rule, the line-break rule, the quote syntax, the exact main example, and a nested-quote follow-up. The details of rendering nested depth were not kept. Our version is about 91% the same as the reported question.

Convert a plain-text email message into a compact markup string made from <Paragraph>, <Quote>, and <Break /> components.

  • One or more empty lines end the current paragraph or quote block.
  • A non-empty line with no leading > belongs to a paragraph. Consecutive paragraph lines are joined with <Break />.
  • A line beginning with one or more > characters belongs to a quote. The number of leading markers is its quote depth, and those markers are removed from the rendered text.
  • Quote depth may increase or decrease between consecutive quote lines. Increasing the depth opens nested <Quote> components. Decreasing it closes components until the requested depth remains.
  • Consecutive text lines at the same quote depth are joined with <Break />.

Return all rendered components concatenated without extra whitespace.

Function

renderEmailMarkup(message: String) → String

Examples

Example 1

message = "Please tag @Bob Jones for approval!\n\nHere's the max amount we were allotted:\n\n>Max spend: $5000\n>Max spend per user: $12\n>Target spend: $3000\n\nDo you think it will be ok?\nOtherwise let's consider a new vendor."return = "<Paragraph>Please tag @Bob Jones for approval!</Paragraph><Paragraph>Here's the max amount we were allotted:</Paragraph><Quote>Max spend: $5000<Break />Max spend per user: $12<Break />Target spend: $3000</Quote><Paragraph>Do you think it will be ok?<Break />Otherwise let's consider a new vendor.</Paragraph>"

Blank lines split the two introductory paragraphs, the three > lines form one quote, and the final single newline becomes a break inside one paragraph.

Example 2

message = "Top\n\n>One\n>>Two\n>Three\n\nEnd"return = "<Paragraph>Top</Paragraph><Quote>One<Quote>Two</Quote><Break />Three</Quote><Paragraph>End</Paragraph>"

The second quote line opens a nested quote. Returning to depth one closes that nested component before adding a break and the next outer-quote line.

Example 3

message = "alpha\nbeta"return = "<Paragraph>alpha<Break />beta</Paragraph>"

Without a blank separator or quote marker, both lines belong to one paragraph.

Constraints

  • 0 <= message.length <= 100000.
  • Line endings use \n.
  • Text contains printable ASCII characters. Outside leading quote markers, it does not contain <, >, or &.
  • A non-empty quote line contains at least one text character after its leading markers.

More Zip Phone Screen questions

  • Maximum Survival Time in a Graph PursuitPHONE SCREEN · Seen Sep 2026
  • Find All Zip Rummy MeldsPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2026
  • Shortest Path Around Moving ParadesPHONE SCREEN · Seen Mar 2026
  • Furthest Building with Sandbags and RopesPHONE SCREEN · Seen Feb 2026
  • Phrase Covering the Most WordsPHONE SCREEN · Seen Feb 2026
  • Translate Values in a Nested MapPHONE SCREEN · Seen Feb 2026
  • Maximum Nonadjacent Sum in a General TreePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2025
  • Shortest Distance in a GraphPHONE SCREEN · Seen Nov 2025
  • Open the Lock and Return a Shortest PathPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2025
  • Winning Draws for a Mahjong HandPHONE SCREEN · Seen Sep 2025

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
  • Rich Text Parser Part 3 (Depth Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Parse Nested HTML into a TreeApple · ONSITE INTERVIEWApple interview questions
  • Calculator with ParenthesesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions

Zip interview experiences

  • ZipHQ New Grad OA and Interview Questions: 11 Experiences
  • Zip SWE Interview Timelines: 31 Experiences (Part 2 of 2)
  • Zip SWE OA and Interview Questions: 31 Experiences (Part 1 of 2)
All Zip interview questionsSee Zip hiring insights
Saved
class Solution {
    public String renderEmailMarkup(String message) {
        // Write your code here.
    }
}

Not a valid String

Not a valid String

Checking account…