InterviewDB Experience · Los Angeles

DOM Tree Manipulation - Build and Query a Simplified HTML DOM

Interview Experience

Problem Implement a simplified in-memory DOM tree. Each node has a tag, optional id, a list of classes, and child nodes. Example Follow-ups How would you support a descendant combinator, e.g., "div p" (all <p> inside <div>)? Implement innerHTML that serializes the subtree back to an HTML string. What traversal strategy does query_selector use? Why BFS vs. DFS matters here. How do you handle query_selector on a very deep tree (10K levels) without stack overflow?

Full Details

🔒

Unlock all Affirm questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a candidate experience report from a affirm interview during the phone round.

It covers the following topics: Strings, Phone, Graph, Coding, Onsite, Stack .