I had an interview with Samsara recently and was asked this problem.
Problem:
We're going to build the beginnings of a markdown processor. Markdown is a markup language that allows you to easily create HTML.
We ll provide some sample input and desired output. Dont worry too much about edge cases, but feel free to ask if you re unsure or think there s something we ought to consider.
Part 1: A markdown processor is capable of handling a multitude of string to html tag formats. For now, we just want to focus on supporting <p/>, <br/>, <blockquote/>, and <del/> tags.
Input:
String input = "This is a paragraph with a soft\n" + "line break.\n\n" + "This is another paragraph that has\n" +
"> Some text that\n" + "> is in a\n" + "> block quote.\n\n" +
"This is another paragraph with a ~~strikethrough~~ word.";
Expected Output:
"<p>This is a paragraph with a soft<br />line break.</p>
<p>This is another paragraph that has <br />
<blockquote.>Some text that<br />is in a<b.r />
block quote</blockquote.> </p> <p>This is another paragraph with a
<del>strikethrough</del.> word.</p>"How to solve these type of problems? Is there some similar problems available on leetcode? Also, what is the level of this problem? Is it LC Easy/Medium/Hard?