You are given the root of a binary tree & a reference node’s value. You have to list all the nodes that are below K levels from the reference node.
Input: Root Node Address (7), Reference Node Value: 6, K=1
Input: Root Node Address (7), Reference Node Value: 6, K=2
Output: 4, 5
Input: Root Node Address (7), Reference Node Value: 3, K=3
Output: 1, 6, 0, 2, 4, 5
Design a browser
This can be a tricky question if we don’t negotiate the scope well.
We need to discuss what all functionalities the interviewer is expecting.
We have to come up with high-level definitions of the classes that we will need.
Basic functionalities that you will have to design for:
- HTML rendering.
- JS execution.
- Fetching resources.
- Tokenization, creating a DOM tree.
- Multiple tabs.
- Resource caching.
- Managing history.
What is an event loop & how would you design one?
This video explains the event loop very well:
When it comes to designing an event loop you will have come up with class definitions for all the components of the event loop & explain how a task will move from one component to another.
Determine the output, the order in which console.logs will be executed.
You are given an array of stock prices over days. You have to determine what is the maximum profit one can make provided a single transaction can be done.
Stock Buy Sell to Maximize Profit - GeeksforGeeks
The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in…
Input: [100, 180, 260, 310, 40, 535, 695]
Output: 644 (Buy on the day 4, sell on the day 6)
Here is a list of some preparation material & set of questions:
All the very best :)