Parse Markdown Links Without Regex
Company: Samsara
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency in string parsing, tokenization, escape-sequence handling, and input validation required to convert simplified Markdown-style link syntax into HTML anchors without using regular expressions.
Constraints
- 0 <= len(text) <= 200000
- Do not use regular expressions.
- Only exact unescaped patterns of the form `[label]("url")` should be converted; malformed patterns must remain unchanged.
Examples
Input: ('Click [Go to Link]("whateverlink.com") now.',)
Expected Output: 'Click <a href="whateverlink.com">Go to Link</a> now.'
Explanation: A well-formed link is converted and surrounding text is preserved.