- Implement a utility function/class commonly found in libraries/frameworks.
- Find out what platform you are coding on and familiarize yourself with the coding environment:
- The supported editor shortcuts.
- Whether you can execute code.
- Whether you can install dependencies beforehand.
- Make your self introduction under a minute. Unless requested, do not take longer than this otherwise you might not have enough time to code.
- Ask clarifying questions upon receiving the question. Clarify the following:
- Whether the code is meant to run in the browser or on the server (e.g. Node.js).
- Browser support, as this will affect the browser APIs you can use.
- Code out your solution and explain your code to your interviewer while you are coding.
- After coding, read through your code once and try to spot basic errors like typos, using variables before initializing them, using APIs incorrectly, etc.
- Outline some basic test cases and some edge cases. Test your code with these cases and determine if your code passes them. If it fails, debug the issue(s) and fix them.
- Optional: Explain the time/space complexity if the code involved algorithmic optimizations.
- Explain any tradeoffs you made, cases you explicitly didn't handle, and how you would improve the code if you had more time.
- The interview might not end here, the interviewer might have follow-up questions for you on this question or give you another question. Be prepared for them.
|Data Structures||Arrays, Maps, Stacks, Trees, Sets|
|Algorithms||Binary Search, Breadth-first Search, Depth-first Search, Recursion|
Promise, Handling variadic arguments
|DOM||DOM traversal, DOM creation, DOM manipulation, Accessing element/node properties, Event delegation|
|Runtime APIs||Timer (|
- Problem Solving: Use a systematic and logical approach to understanding and addressing a problem. Break down the problem into smaller independent problems. Evaluate different approaches and their tradeoffs.
- Software Engineering Foundation: Familiarity with data structures, algorithms, runtime complexity analysis, use of design patterns, design solution with clean abstractions.
- Communication: Ask questions to clarify details and clearly explaining one's approach and considerations.
- Verification: Identify various scenarios to test the code against, including edge cases. Be able to diagnose and fix any issues that arise.
- Aim to write pure functions which have the benefit of reusability and modularity. aka functions which don't rely on state outside of the function and doesn't cause side effects.
- Complexity arising due to recursion:
- If you have identified that solving the question requires recursion, ask about the input size and how to handle the case of recursion stack overflow. Usually you won't have to handle it but raising this issue is a good signal.
- Nested deep data structures can have recursive references to itself, which makes certain operations like serialization much trickier. Ask the interviewer if you have to handle such cases. Usually you won't have to handle it but raising this issue is a good signal.
Note that we are intentionally vague in some of the questions and don't present the full requirements upfront in the question description. However, we'll cover as much ground as possible in the solution. It may be frustrating while reading the solutions to see that you've missed out some stuff, but this trains you to think ahead and consider what are the possible things you have to take note of when working on the solution. Better to find out during practice than during actual interviews.