Amazon logo

Amazon Frontend Engineer System Design Questions

40 practice questions for Amazon Frontend Engineer interviews

Amazon frontend engineer interviews emphasise JavaScript, DOM manipulation, CSS, accessibility, browser APIs, and UI component architecture.

All Roles Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer

No verified questions yet for Amazon.

system design Senior api design #1

1. [OA] Design a Virtual DOM Differ for Amazon's Frontend

In order to optimize rendering performance in Amazon's web applications, a Virtual DOM is used for efficient updates. This problem involves designing the diffing algorithm which reconciles changes in a virtual representation of the DOM.
### Class Signature
python
class VirtualDOM {
def create_element(self, tag: str, props: dict, children: List[Union[str, 'VirtualDOM']]) -> None:
# Create a virtual DOM element
def diff(self, old_tree: 'VirtualDOM', new_tree: 'VirtualDOM') -> List[str]:
# Compute the difference between two trees
}

### Example Method Signatures
- create_element(tag: str, props: dict, children: List[Union[str, 'VirtualDOM']]) -> None: Creates a virtual DOM element.
- diff(old_tree: 'VirtualDOM', new_tree: 'VirtualDOM') -> List[str]: Returns a list of operations needed to update the DOM based on differences.
### Example 1:
Input:
old_tree = create_element('div', {'id': '1'}, ['Hello', 'World'])
new_tree = create_element('div', {'id': '1'}, ['Hello', 'Amazon'])
Output: ['UPDATE_TEXT: 1, Amazon']
### Constraints:
- 1 <= number of elements in tree <= 1000
- Tags and props are limited to valid HTML attributes.

Related Amazon Frontend Engineer interview prep

Start practicing Amazon questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free