@ -1,5 +1,5 @@
|
||||
# Algorithms
|
||||
|
||||
The contents have been moved to the [website](https://www.techinterviewhandbook.org/algorithms/introduction).
|
||||
The contents have been moved to the [website](https://www.techinterviewhandbook.org/algorithms/study-cheatsheet).
|
||||
|
||||
<!-- TODO: Remove in future -->
|
||||
|
@ -0,0 +1,42 @@
|
||||
import React from 'react';
|
||||
|
||||
import QuestionGroups from './QuestionGroups.json';
|
||||
|
||||
export default function QuestionList() {
|
||||
return (
|
||||
<div className="padding-vert--lg">
|
||||
{Object.entries(QuestionGroups).map(
|
||||
([sectionTitle, questions], index) => (
|
||||
<div className="margin-bottom--lg" key={sectionTitle}>
|
||||
<h4>Week {index + 5}</h4>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Problem</th>
|
||||
<th>Difficulty</th>
|
||||
<th>Duration</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{questions.map((question) => (
|
||||
<tr key={question.slug}>
|
||||
<td>
|
||||
<a
|
||||
href={question.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferer">
|
||||
{question.title}
|
||||
</a>
|
||||
</td>
|
||||
<td>{question.difficulty}</td>
|
||||
<td>{question.duration} mins</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,18 +1,53 @@
|
||||
---
|
||||
id: algorithms-introduction
|
||||
title: Algorithms tips
|
||||
description: Here are practical tips for each algorithm topic and data structure which appear frequently in coding interviews
|
||||
id: study-cheatsheet
|
||||
title: Data structures and algorithms study cheatsheets for coding interviews
|
||||
description: Study guides for coding interviews with focus on data structures and algorithms, including practice questions, techniques, time complexity and recommended resources
|
||||
keywords: [coding interview algorithms, coding interview data structures]
|
||||
sidebar_label: Introduction
|
||||
slug: introduction
|
||||
---
|
||||
|
||||
import InDocAd from '../\_components/InDocAd';
|
||||
|
||||
This section dives deep into practical knowledge and techniques for algorithms and data structures which appear frequently in algorithm interviews. The more techniques you have in your arsenal, the higher the chances of passing the interview. They may lead you to discover corner cases you might have missed out or even lead you towards the optimal approach!
|
||||
## What is this
|
||||
|
||||
For each topic, a brief introduction is given, along with language-specific libraries to use, time complexities cheatsheet, things to look out for during interviews, corner cases, useful techniques, and recommended resources to help you master the topic. Lastly, there is a list of recommended common questions to practice which in my opinion is highly valuable for mastering the core concepts for the topic.
|
||||
This section dives deep into practical knowledge and techniques for algorithms and data structures which appear frequently in algorithm interviews. The more techniques you have in your arsenal, the higher the chances of passing the interview. They may lead you to discover corner cases you might have missed out or even lead you towards the optimal approach!
|
||||
|
||||
If you are interested in how data structures are implemented, check out [Lago](https://github.com/yangshun/lago), a Data Structures and Algorithms library for JavaScript.
|
||||
## Contents of each study guide
|
||||
|
||||
For each topic, you can expect to find:
|
||||
|
||||
1. A brief overview
|
||||
1. Learning resources
|
||||
1. Language-specific libraries to use
|
||||
1. Time complexities cheatsheet
|
||||
1. Things to look out for during interviews
|
||||
1. Corner cases
|
||||
1. Useful techniques vRecommended questions to practice
|
||||
|
||||
## Study guides list
|
||||
|
||||
Here is the list of data structures and algorithms you should prepare for coding interviews and their corresponding study guides:
|
||||
|
||||
| Topic | Priority |
|
||||
| ---------------------------------------------------------- | -------- |
|
||||
| [Array](./algorithms/array.md) | High |
|
||||
| [String](./algorithms/string.md) | High |
|
||||
| [Hash Table](./algorithms/hash-table.md) | Mid |
|
||||
| [Recursion](./algorithms/recursion.md) | Mid |
|
||||
| [Sorting and searching](./algorithms/sorting-searching.md) | High |
|
||||
| [Matrix](./algorithms/matrix.md) | High |
|
||||
| [Linked List](./algorithms/linked-list.md) | Mid |
|
||||
| [Queue](./algorithms/queue.md) | Mid |
|
||||
| [Stack](./algorithms/stack.md) | Mid |
|
||||
| [Tree](./algorithms/tree.md) | High |
|
||||
| [Graph](./algorithms/graph.md) | High |
|
||||
| [Heap](./algorithms/heap.md) | Mid |
|
||||
| [Trie](./algorithms/trie.md) | Mid |
|
||||
| [Interval](./algorithms/interval.md) | Mid |
|
||||
| [Dynamic programming](./algorithms/dynamic-programming.md) | Low |
|
||||
| [Binary](./algorithms/binary.md) | Low |
|
||||
| [Math](./algorithms/math.md) | Low |
|
||||
| [Geometry](./algorithms/geometry.md) | Low |
|
||||
|
||||
## General interview tips
|
||||
|
@ -0,0 +1,201 @@
|
||||
---
|
||||
id: behavioral-interview-questions
|
||||
title: The 30 most common Software Engineer behavioral interview questions
|
||||
description: How to prepare for Software Engineer behavioral interviews
|
||||
keywords:
|
||||
[
|
||||
software engineer behavioral interview questions,
|
||||
software engineering behavioral questions,
|
||||
software developer behavioral interview questions,
|
||||
software engineer behavioral questions,
|
||||
amazon software engineer behavioral interview questions,
|
||||
behavioral interview software engineer,
|
||||
how to prepare for behavioral interview software engineer,
|
||||
]
|
||||
sidebar_label: Most common behavioral questions to prepare
|
||||
---
|
||||
|
||||
In the software engineer interview process, behavioral interviews may seem so much more varied and unstructured as compared to technical interviews. However, in most cases, the interviewer is actually just trying to get to know you better and there's always a set of common questions that need to be asked to achieve that.
|
||||
|
||||
## Most commonly asked behavioral questions across top tech companies
|
||||
|
||||
Here are some of the 30 most commonly asked behavioral interview questions across top tech companies:
|
||||
|
||||
1. Why do you want to work for X company?
|
||||
1. Why do you want to leave your current/last company?
|
||||
1. What are you looking for in your next role?
|
||||
1. Tell me about a time when you had a conflict with a co-worker.
|
||||
1. Tell me about a time in which you had a conflict and needed to influence somebody else.
|
||||
1. What project are you currently working on?
|
||||
1. What is the most challenging aspect of your current project?
|
||||
1. What was the most difficult bug that you fixed in the past 6 months?
|
||||
1. How do you tackle challenges? Name a difficult challenge you faced while working on a project, how you overcame it, and what you learned.
|
||||
1. What are you excited about?
|
||||
1. What frustrates you?
|
||||
1. Imagine it is your first day here at the company. What do you want to work on? What features would you improve on?
|
||||
1. What are the most interesting projects you have worked on and how might they be relevant to this company's environment?
|
||||
1. Tell me about a time you had a disagreement with your manager.
|
||||
1. Talk about a project you are most passionate about, or one where you did your best work.
|
||||
1. What does your best day of work look like?
|
||||
1. What is something that you had to push for in your previous projects?
|
||||
1. What is the most constructive feedback you have received in your career?
|
||||
1. What is something you had to persevere at for multiple months?
|
||||
1. Tell me about a time you met a tight deadline.
|
||||
1. If this were your first annual review with our company, what would I be telling you right now?
|
||||
1. Time management has become a necessary factor in productivity. Give an example of a time-management skill you've learned and applied at work.
|
||||
1. Tell me about a problem you've had getting along with a work associate.
|
||||
1. What aspects of your work are most often criticized?
|
||||
1. How have you handled criticism of your work?
|
||||
1. What strengths do you think are most important for _your job position_?
|
||||
1. What words would your colleagues use to describe you?
|
||||
1. What would you hope to achieve in the first six months after being hired?
|
||||
1. Tell me why you will be a good fit for the position.
|
||||
|
||||
## Airbnb Software Engineer behavioral interview questions
|
||||
|
||||
While loving to travel or appreciating Airbnb's growth may be good answers, try to demonstrate the deep connection you have with the product.
|
||||
|
||||
- What does "belong anywhere" mean to you?
|
||||
- What large problems in the world would you solve today?
|
||||
- Why do you like Airbnb?
|
||||
- If you had an unlimited budget and you could buy one gift for one person, what would you buy and who would you buy it for?
|
||||
- If you had an unlimited budget and you could go somewhere, where would you go?
|
||||
- Share one of your trips with us.
|
||||
- What is the most challenging project in or out of school that you have worked on in the last 6 months.
|
||||
- What is something that you don't want from your last internship/job?
|
||||
- Give me an example of when you've been a good host.
|
||||
- What's something you'd like to remove from the Airbnb experience?
|
||||
- What is something new that you can teach your interviewer in a few minutes?
|
||||
- Tell me about why you want to work here.
|
||||
- What is the best gift you have ever given or received?
|
||||
- Tell me about a time you were uncomfortable and how you dealt with it.
|
||||
- Explain a project that you worked on recently.
|
||||
- What do you think of Airbnb?
|
||||
- Tell me something about yourself and why you'd be a good fit for the position.
|
||||
- Name a situation where you were impressed by a company's customer service.
|
||||
- How did you work with senior management on large projects as well as multiple internal teams?
|
||||
- Tell me about a time you had to give someone terrible news.
|
||||
- If you were a gerbil, which gerbil would you be?
|
||||
- What excites you about the company?
|
||||
- How does Airbnb impact our guests and hosts?
|
||||
- What part of our mission resonates the most with you?
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.com/Interview/Airbnb-Interview-Questions-E391850.htm)
|
||||
|
||||
## Amazon Software Engineer behavioral interview questions
|
||||
|
||||
- How do you deal with a failed deadline?
|
||||
- Why do you want to work for Amazon?
|
||||
- Tell me about a situation where you had a conflict with a teammate.
|
||||
- In your professional experience have you worked on something without getting approval from your manager?
|
||||
- Tell me a situation where you would have done something differently from what you actually did.
|
||||
- What is the most exceedingly bad misstep you've made at any point?
|
||||
- Describe what Human Resources means to you.
|
||||
- How would you improve Amazon's website?
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.com/Interview/Amazon-Interview-Questions-E6036.htm)
|
||||
|
||||
## ByteDance Software Engineer behavioral interview questions
|
||||
|
||||
- What do you know about <role> and why?
|
||||
- Take me through a product you launched from start to end
|
||||
- What's the biggest achievement in your previous projects?
|
||||
- Tell me about a recent failure and what you learned from the experience
|
||||
- Why do you want to work at ByteDance?
|
||||
- What makes you a good fit for this position?
|
||||
- What excites you about the role?
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.sg/Interview/ByteDance-Interview-Questions-E1624196.htm)
|
||||
|
||||
## Dropbox Software Engineer behavioral interview questions
|
||||
|
||||
- Talk about your favorite project.
|
||||
- If you were hired here what would you do?
|
||||
- State an experience about how you solved a technical problem. Be specific about the diagnosis and process.
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.com/Interview/Dropbox-Interview-Questions-E415350.htm)
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## Hired Software Engineer behavioral interview questions
|
||||
|
||||
- Tell me about yourself.
|
||||
- What is your biggest strength and area of growth?
|
||||
- Why are you interested in this opportunity?
|
||||
- What are your salary expectations?
|
||||
- Why are you looking to leave your current company?
|
||||
- Tell me about a time your work responsibilities got a little overwhelming. What did you do?
|
||||
- Give me an example of a time when you had a difference of opinion with a team member. How did you handle that?
|
||||
- Tell me about a challenge you faced recently in your role. How did you tackle it? What was the outcome?
|
||||
- Where do you want to be in five years?
|
||||
- Tell me about a time you needed information from someone who wasn't responsive. What did you do?
|
||||
|
||||
Source: [Glassdoor](https://hired.com/blog/candidates/10-top-interview-questions-how-to-answer/)
|
||||
|
||||
## Lyft Software Engineer behavioral interview questions
|
||||
|
||||
- Tell me about your most interesting/challenging project to date.
|
||||
- Why Lyft? What are you looking for in the next role?
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.com/Interview/Lyft-Interview-Questions-E700614.htm)
|
||||
|
||||
## Palantir Software Engineer behavioral interview questions
|
||||
|
||||
- **What is something 90% of people disagree with you about?**
|
||||
- **What is broken around you?**
|
||||
- How do you deal with difficult coworkers? Think about specific instances where you resolved conflicts.
|
||||
- How did you win over the difficult employees?
|
||||
- Tell me about an analytical problem that you have worked on in the past.
|
||||
- What are your three strengths and three weaknesses?
|
||||
- If you were in charge of picking projects for Palantir, what problem would you try to solve?
|
||||
- What are some of the best and worst things about your current company?
|
||||
- What would your manager say about you?
|
||||
- Describe Palantir to your grandmother.
|
||||
- Teach me something you've learned.
|
||||
- Tell me a time when you predicted something.
|
||||
- If your supervisors were to rate you on a scale of 1-10, what would they rate you?
|
||||
- What was the most fun thing you did recently?
|
||||
- Tell me the story of how you became who you are today and what made you apply to Palantir.
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.com/Interview/Palantir-Technologies-Interview-Questions-E236375.htm)
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Slack Software Engineer behavioral interview questions
|
||||
|
||||
- Tell me something about your internship.
|
||||
- Why do you want to join Slack?
|
||||
- Tell me about your past projects.
|
||||
- Explain me your toughest project and the working architecture.
|
||||
- Apart from technical knowledge, what did you learn during your internship?
|
||||
- If someone has a different viewpoint to do a project like different programming language, how would handle this situation?
|
||||
- What are your most interesting subjects and why?
|
||||
- Did you find any bugs in Slack?
|
||||
- What is your favorite feature and why?
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.com/Interview/Slack-Interview-Questions-E950758.htm)
|
||||
|
||||
## Stack Overflow Software Engineer behavioral interview questions
|
||||
|
||||
- What have you built?
|
||||
- What is the hardest technical problem you have run into?
|
||||
- How did you solve it?
|
||||
- Where do you see yourself in 5 years?
|
||||
- Why do you want to work here?
|
||||
- How do you handle disagreements with co-workers?
|
||||
|
||||
Source: [Glassdoor](https://hired.com/blog/candidates/10-top-interview-questions-how-to-answer/)
|
||||
|
||||
## Stripe Software Engineer behavioral interview questions
|
||||
|
||||
- How do you stay up to date with the latest technologies?
|
||||
- Explain a project that you worked on recently that was difficult.
|
||||
- Where do you see yourself in five years?
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.com/Interview/Stripe-Interview-Questions-E671932.htm)
|
||||
|
||||
## Twitter Software Engineer behavioral interview questions
|
||||
|
||||
- What would your previous boss say your biggest strength was?
|
||||
|
||||
Source: [Glassdoor](https://www.glassdoor.com/Interview/Twitter-Interview-Questions-E100569.htm)
|
@ -0,0 +1,186 @@
|
||||
---
|
||||
id: coding-interview-best-practices
|
||||
title: 'Coding interview best practices: What to do to display hire signals'
|
||||
description: Tips on what to do before, during and after coding interviews to display hire signals according to coding interview evaluation criteria
|
||||
keywords:
|
||||
[
|
||||
coding interview best practices,
|
||||
best practices for coding interviews,
|
||||
what to do during coding interview,
|
||||
what to do after coding interview,
|
||||
what to do before coding interview,
|
||||
how to display hire behavior in coding interview,
|
||||
how to pass coding interview,
|
||||
]
|
||||
sidebar_label: Best practices during coding interviews
|
||||
---
|
||||
|
||||
As coding interviews mature over the years, there are now firmer expectations on how candidates should behave during a coding interview. Some of these practices also help you to exhibit "hire" signals to the interviewer by displaying your ability to communicate well and deal with roadblocks.
|
||||
|
||||
Deriving the best practices from top candidates and also based on [how you will be evaluated during a coding interview](./coding-interview-rubrics.md), we have summarized some of the top tips for how to behave during a coding interview in an exhaustive checklist - including top mistakes to avoid.
|
||||
|
||||
You should read and familiarize with this guide even before you start practicing your coding interview questions. Accompanying LeetCode grinding with this guide will allow you to ingrain these important coding interview behaviors early on.
|
||||
|
||||
## What to do _before_ your coding interview
|
||||
|
||||
- ✅ Dress comfortably.
|
||||
> Usually you do not need to wear smart clothes, casual should be fine. T-shirts and jeans are acceptable at most places.
|
||||
- ✅ Ensure you have read and prepared for your [self introduction](./self-introduction.md) and [final questions to ask](./final-questions.md).
|
||||
|
||||
### For virtual onsite coding interviews
|
||||
|
||||
<div className="text--center margin-vert--lg">
|
||||
<figure>
|
||||
<img alt="Summary of what to do before a virtual onsite coding interview"
|
||||
title="Summary of what to do before a virtual onsite coding interview" className="shadow--md" src={require('@site/static/img/what-to-do-before-a-virtual-onsite-coding-interview.jpg').default} style={{maxWidth: 'min(100%, 420px)'}} />
|
||||
<figcaption>What to do before a virtual onsite coding interview</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
- ✅ Prepare pen and paper.
|
||||
> In case you need to jot and visualize stuff. Drawings are especially helpful for trees / graphs questions
|
||||
- ✅ Use earphones or headphones and make sure you are in a quiet environment.
|
||||
> Avoid using speakers because if the echo is loud, communication is harder and participants repeating themselves will just result in loss of valuable time.
|
||||
- ✅ Check that your internet connection is working.
|
||||
- ✅ Check that your webcam and audio are working.
|
||||
- ✅ Familiarize and set up shortcuts in the coding environment (CoderPad / CodePen).
|
||||
> Set up the editor shortcuts, turn on autocompletion, tab spacing, etc. Interviewers are impressed if you know the shortcuts and use them well
|
||||
- ✅ Turn off the webcam if possible.
|
||||
> Most remote interviews will not require video chat and leaving it on only serves as a distraction and hogs network bandwidth.
|
||||
|
||||
### For phone screen coding interviews
|
||||
|
||||
<div className="text--center margin-vert--lg">
|
||||
<figure>
|
||||
<img alt="Summary of what to do before a phone screen coding interview"
|
||||
title="Summary of what to do before a phone screen coding interview" className="shadow--md" src={require('@site/static/img/what-to-do-before-a-phone-screen-coding-interview.jpg').default} style={{maxWidth: 'min(100%, 420px)'}} />
|
||||
<figcaption>What to do before a phone screen coding interview</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
- ✅ Use earphones and put the phone on the table.
|
||||
> Avoid holding a phone in one hand and only having one other hand to type
|
||||
- ✅ Request for the option to use Zoom/Google Meet/Hangouts or Skype instead of a phone call.
|
||||
> It is easier to send links or text across.
|
||||
|
||||
## For onsite whiteboarding coding interviews
|
||||
|
||||
- ✅ Learn about whiteboard space management.
|
||||
> Leave space between lines of code in case you need to insert lines between existing code.
|
||||
|
||||
## What to do _during_ your coding interview
|
||||
|
||||
<div className="text--center margin-vert--lg">
|
||||
<figure>
|
||||
<img alt="Summary of what to do during a coding interview"
|
||||
title="Summary of what to do during a coding interview" className="shadow--md" src={require('@site/static/img/what-to-do-during-a-coding-interview.jpg').default} style={{maxWidth: 'min(100%, 420px)'}} />
|
||||
<figcaption>What to do during a coding interview</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
### 1. Make a good self introduction at the start of the interview
|
||||
|
||||
- ✅ Introduce yourself in a few sentences under a minute or 2.
|
||||
> Follow our guide on how to make a good self introduction for software engineers
|
||||
- ✅ Sound enthusiastic!
|
||||
> Speak with a smile and you will naturally sound more engaging.
|
||||
- ❌ Do not spend too long on your self introduction as you will have less time left to code.
|
||||
|
||||
### 2. Upon receiving the question, make clarifications
|
||||
|
||||
**Do not jump into coding right away.** Coding questions tend to be vague and underspecified on purpose to allow the interviewer to gauge the candidate's attention to detail and carefulness. Ask at least 2-3 clarifying questions.
|
||||
|
||||
- ✅ Paraphrase and repeat the question back at the interviewer.
|
||||
> Make sure you understand exactly what they are asking.
|
||||
- ✅ Clarify assumptions (Refer to [algorithms cheatsheets](.//algorithms/study-cheatsheet.md) for common assumptions)
|
||||
- > A tree-like diagram could very well be a graph that allows for cycles and a naive recursive solution would not work. Clarify if the given diagram is a tree or a graph.
|
||||
- > Can you modify the original array / graph / data structure in any way?
|
||||
- > How is the input stored?
|
||||
- > If you are given a dictionary of words, is it a list of strings or a Trie?
|
||||
- > Is the input array sorted? (e.g. for deciding between binary / linear search)
|
||||
- ✅ Clarify input value range.
|
||||
> Inputs: how big and what is the range?
|
||||
- ✅ Clarify input value format
|
||||
> Values: Negative? Floating points? Empty? Null? Duplicates? Extremely large?
|
||||
- ✅ Work through a simplified example to ensure you understood the question.
|
||||
> E.g., you are asked to write a palindrome checker, before coding, come up with simple test cases like "KAYAK" => true, "MOUSE" => false, then check with the interviewer if those example cases are in line with their expectations
|
||||
- ❌ Do not jump into coding right away or before the interviewer gives you the green light to do so.
|
||||
|
||||
### 3. Work out and optimize your approach with the interviewer
|
||||
|
||||
The worst thing you can do next is jump straight to coding - interviewers expect there to be some time for a 2-way discussion on the correct approach to take for the question, including analysis of the time and space complexity.
|
||||
|
||||
This discussion can range from a few minutes to up to 5-10 minutes depending on the complexity of the question. This also gives interviewers a chance to provide you with hints to guide you towards an acceptable solution.
|
||||
|
||||
- ✅ If you get stuck on the approach or optimization, use [this structured way](./coding-interview-techniques.md) to jog your memory / find a good approach
|
||||
- ✅ Explain a few approaches that you could take at a high level (don't go too much into implementation details). Discuss the tradeoffs of each approach with your interviewer as if the interviewer was your coworker and you all are collaborating on a problem.
|
||||
> For algorithmic questions, space/time is a common tradeoff. Let's take the famous [Two Sum](https://leetcode.com/problems/two-sum/) question for example. There are two common solutions - (1) use nested for loops. This would be O(n<sup>2</sup>) in terms of time complexity and O(1) in terms of space. (2) In one pass of the array, you would hash a value to its index into a hashmap. For subsequent values, look up the hashmap to see if you can find an existing value that can sum up to the target. This approach is O(N) in terms of both time and space. Discuss both solutions, mention the tradeoffs and conclude on which solution is better (typically the one with lower time complexity)
|
||||
- ✅ State and explain the time and space complexity of your proposed approach(es).
|
||||
> Mention the Big O complexity for time and explain why (e.g O(n<sup>2</sup>) for time because there are nested for loops, O(n) for space because an extra array is created). Master all the time and space complexity using the [algorithm optimization techniques](./coding-interview-techniques.md#how-to-optimize-your-approach-or-solution).
|
||||
- ✅ Agree on the most ideal approach and optimize it. Identify repeated/duplicated/overlapping computations and reduce them via caching. Refer to the page on [optimizing your solution](./coding-interview-techniques.md#how-to-optimize-your-approach-or-solution).
|
||||
- ❌ Do not jump into coding right away or before the interviewer gives you the green light to do so.
|
||||
- ❌ Do not ignore any piece of information given.
|
||||
- ❌ Do not appear unsure about your approach or analysis.
|
||||
|
||||
### 4. Code out your solution while talking through it
|
||||
|
||||
- ✅ Only start coding after you have explained your approach and the interviewer has given you the green light.
|
||||
- ✅ Explain what you are trying to achieve as you are coding / writing. Compare different coding approaches where relevant.
|
||||
> In so doing, demonstrate mastery of your chosen programming language.
|
||||
- ✅ Code / write at a reasonable speed so you can talk through it - but not too slow.
|
||||
> You want to type slow enough so you can explain the code, but not too slow as you may run out of time to answer all questions
|
||||
- ✅ Write actual compilable, working code where possible, not pseudocode.
|
||||
- ✅ Write clean, straightforward and neat code with as few syntax errors / bugs as possible.
|
||||
> Always go for a clean, straightforward implementation than a complex, messy one. Ensure you adopt a neat coding style and good coding practices as per language paradigms and constructs. Syntax errors and bugs should be avoided as much as possible.
|
||||
- ✅ Use variable names that explain your code.
|
||||
> Good variable names are important because you need to explain your code to the interviewer. It's better to use long variable names that explain themselves. Let's say you need to find the multiples of 3 in an array of numbers. Name your results array `multiplesOfThree` instead of array/numbers.
|
||||
- ✅ Ask for permission to use trivial functions without having to implement them.
|
||||
> E.g. `reduce`, `filter`, `min`, `max` should all be ok to use
|
||||
- ✅ Write in a modular fashion, going from higher-level functions and breaking them down into smaller helper functions.
|
||||
> Let's say you're asked to build a car. You can just write a few high level functions first: `gatherMaterials()`, `assemble()`. Then break down `assemble()` into smaller functions, `makeEngine()`, `polishWheels()`, `constructCarFrame()`. You could even ask the interviewer if it's ok to not code out some trivial helper functions.
|
||||
- ✅ If you are cutting corners in your code, state that out loud to your interviewer and say what you would do in a non-interview setting (no time constraints).
|
||||
> E.g., "Under non-interview settings, I would write a regex to parse this string rather than using `split()` which may not cover certain edge cases."
|
||||
- ✅ [Onsite / Whiteboarding] Practice whiteboard space management
|
||||
- ❌ Do not interrupt your interviewer when they are talking. Usually if they speak, they are trying to give you hints or steer you in the right direction.
|
||||
- ❌ Do not spend too much time writing comments.
|
||||
- ❌ Do not repeat yourself
|
||||
- ❌ Do not use bad variable names.
|
||||
- Do not use extremely verbose or single-character variable names, (unless they're common like `i`, `n`) variable names
|
||||
- ❌ Do not copy and paste code without checking (e.g. some variables might need to be renamed after pasting).
|
||||
|
||||
### 5. After coding, check your code and add test cases
|
||||
|
||||
Once you are done coding, do not announce that you are done. Interviewers expect you to start scanning for mistakes and adding test cases to improve on your code.
|
||||
|
||||
- ✅ Scan through your code for mistakes - such as off-by-one errors.
|
||||
> Read through your code with a fresh pair of eyes - as if it's your first time seeing a piece of code written by someone else - and talk through your process of finding mistakes
|
||||
- ✅ Brainstorm edge cases with the interviewer and add additional test cases. (Refer to [algorithms cheatsheets](.//algorithms/study-cheatsheet.md) for common corner cases)
|
||||
> Given test cases are usually simple by design. Brainstorm on possible edge cases such as large sized inputs, empty sets, single item sets, negative numbers.
|
||||
- ✅ Step through your code with those test cases.
|
||||
- ✅ Look out for places where you can refactor.
|
||||
- ✅ Reiterate the time and space complexity of your code.
|
||||
> This allows you to remind yourself to spot issues within your code that could deviate from the original time and space complexity.
|
||||
- ✅ Explain trade-offs and how the code / approach can be improved if given more time.
|
||||
- ❌ Do not immediately announce that you are done coding. Do the above first!
|
||||
- ❌ Do not argue with the interviewer. They may be wrong but that is very unlikely given that they are familiar with the question.
|
||||
|
||||
### 6. At the end of the interview, leave a good impression
|
||||
|
||||
- ✅Ask good final questions that are tailored to the company.
|
||||
> Read tips and [sample final questions to ask](./final-questions.md).
|
||||
- ✅ Thank the interviewer
|
||||
- ❌ Do not end the interview without asking any questions.
|
||||
|
||||
## What to do _after_ your coding interview
|
||||
|
||||
<div className="text--center margin-vert--lg">
|
||||
<figure>
|
||||
<img alt="Summary of what to do after a coding interview"
|
||||
title="Summary of what to do after a coding interview" className="shadow--md" src={require('@site/static/img/what-to-do-after-a-coding-interview.jpg').default} style={{maxWidth: 'min(100%, 420px)'}} />
|
||||
<figcaption>What to do after a coding interview</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
- ✅ Record the interview questions and answers down as these can be useful for future reference.
|
||||
- ✅ Send a follow up email or Linkedin invitation to your interviewer(s) thanking them for their time and the opportunity to interview with them.
|
||||
> As an interviewer myself, these can leave a lasting impression on me.
|
@ -0,0 +1,145 @@
|
||||
---
|
||||
id: coding-interview-rubrics
|
||||
title: How candidates are evaluated in coding interviews at top tech companies
|
||||
description: Detailed coding interview rubrics collated from Google, Amazon, Apple, Netflix
|
||||
keywords:
|
||||
[
|
||||
coding interview rubric,
|
||||
coding interview evaluation criteria,
|
||||
coding interview criteria,
|
||||
coding interview grading rubric,
|
||||
technical interview rubric,
|
||||
]
|
||||
sidebar_label: Coding interview rubrics
|
||||
---
|
||||
|
||||
Ever wondered how coding interviews are evaluated at top tech companies like Google, Amazon, Apple and Netflix?
|
||||
|
||||
Across top tech companies, coding interview evaluation criteria actually does not differ to a great extent. While the exact terms used in the rubric could be different, the dimensions evaluated are roughly similar.
|
||||
|
||||
I will go into detail on the general coding interview evaluation process across big tech companies in this guide. I've also included an [example rubric](./coding-interview-rubrics.md) you can use while practicing on your own or with your peers.
|
||||
|
||||
If you haven't done so already, do refer to my [Coding interview best practices cheatsheet](./coding-interview-best-practices.md) which basically synthesizes what candidates should do to fulfill the evaluated criteria in coding interviews.
|
||||
|
||||
## Candidate scoring methodology
|
||||
|
||||
Generally across FAANG / MANGA companies, coding interview evaluation rubrics can be split broadly into 4 dimensions:
|
||||
|
||||
1. Communication - Does the candidate make clarifications, communicate their approach and explain while coding?
|
||||
1. Problem Solving - Does the candidate show they understand the problem and are able to come up with a sound approach, conduct trade-offs analysis and optimize their approach?
|
||||
1. Technical Competency - How fast and accurate is the implementation? Were there syntax errors?
|
||||
1. Testing - Was the code tested for common and corner cases? Did they self-correct bugs?
|
||||
|
||||
There are 2 general methods of candidate scoring in coding interviews:
|
||||
|
||||
1. Provide a score (e.g. 1-4) for every dimension and sum them up into an overall score
|
||||
1. Provide an overall score (e.g. 1-4) based on overall performance across dimensions
|
||||
|
||||
Regardless of the method used, the scoring bands are generally:
|
||||
|
||||
- Strong hire
|
||||
- Hire
|
||||
- No hire
|
||||
- Strong no hire
|
||||
|
||||
Some companies may have a middle band for indecision when the interviewer feels that the candidate requires more assessment.
|
||||
|
||||
## How does your score impact the result?
|
||||
|
||||
Regardless of the scoring methodology, the final score is based on the overall performance across evaluated criteria (not purely through a certain mathematical cut-off).
|
||||
|
||||
For each phone screen round, there's typically only 1 interviewer, hence if they don't give you a "pass" equivalent to "Leaning hire" and above, you would not proceed to the full interview loop. If there were no clear signals obtained from the round, you might be asked to do a follow up phone screen round.
|
||||
|
||||
Most top tech companies allow candidates to go through every interview round in the full interview loop before making a decision based on the final package. If a candidate receives mixed results (some "pass" and some "fail") from different rounds, interviewers will convene for a discussion based on the signals you displayed. This is why your performance throughout the interview loop is important.
|
||||
|
||||
In certain cases, like follow up phone screen rounds, candidates may be invited for additional assessment rounds if:
|
||||
|
||||
- There were aspects that were missed out in the assessment e.g. 2 coding round interviewers gave very similar questions
|
||||
- Candidate displayed mixed signals in particular areas and additional rounds are required to obtain more reliable signals
|
||||
|
||||
Generally, your scores and feedback for each round are visible to all interviewers. Sometimes, interviewers can even see feedback from your interviews at the same company in the past to avoid asking the same question again. Companies want to see that you have grown as compared to the past. So if you got rejected in the past by a company, reflect on possible reasons and address them if/when you interview with that company again.
|
||||
|
||||
## Detailed explanation of each evaluated criteria
|
||||
|
||||
### 1. Communication
|
||||
|
||||
Basic communication signals:
|
||||
|
||||
- Asks appropriate clarifying questions
|
||||
- Communicates approach, rationale and tradeoffs
|
||||
- Constantly communicating, even while coding
|
||||
- Well organized, succinct, clear communication
|
||||
|
||||
| Score | Overall evaluation |
|
||||
| --- | --- |
|
||||
| Strong hire | Throughout the interview, communication was thorough, well-organized, succinct and clear in terms of thought process - including how they understand the question, their approach, trade-offs.<br/>Interviewer had no challenge following and understanding the candidate's thought process at all. |
|
||||
| Leaning hire | Throughout the interview, communication was sufficient, clear and organized.<br/>However, the interviewer had to ask follow-up questions to understand the candidate on certain aspects such as their approach or thought process. |
|
||||
| Leaning no hire | Throughout the interview, communication was (1 or more of the following): (1) Insufficient (e.g. jumped into coding without explaining), (2) Disorganized or unclear<br/>Interviewer had difficulty following the candidate's thought process. |
|
||||
| Strong no hire | Could not communicate with any clarity or stayed silent even when addressed by the interviewer.<br/>Interviewer had extreme difficulty following the candidate's thought process. |
|
||||
|
||||
### 2. Problem solving
|
||||
|
||||
Basic problem solving signals:
|
||||
|
||||
- Understands the problem quickly by asking good clarifying questions
|
||||
- Approached the problem systematically and logically
|
||||
- Was able to come up with an optimized solution
|
||||
- Determined time and space complexity accurately
|
||||
- Did not require any major hints from the interviewer
|
||||
|
||||
Advanced problem solving signals:
|
||||
|
||||
- Came up with multiple solutions
|
||||
- Explained trade-offs of each solution clearly and correctly, concluded on which of them are most suitable for the current scenario
|
||||
- Had time to discuss follow up problems/extensions
|
||||
|
||||
| Score | Overall evaluation |
|
||||
| --- | --- |
|
||||
| Strong hire | Demonstrated testing signals effortlessly. |
|
||||
| Leaning hire | Had some difficulty demonstrating testing signals, such as not being able to identify all the relevant corner cases. |
|
||||
| Leaning no hire | Conducted testing but did not handle corner cases. Not able to identify or correct bugs in code. |
|
||||
| Strong no hire | Did not even test code against typical cases. Did not spot glaring bugs in the code and announced they are done |
|
||||
|
||||
### 3. Technical competency
|
||||
|
||||
Basic technical competency signals:
|
||||
|
||||
- Translates discussed solution into working code with minimal to no bugs
|
||||
- Clean and straightforward implementation with no syntax errors and unnecessary code, good coding practices e.g. DRY (Don't repeat yourself), uses proper abstractions
|
||||
- Neat coding style (proper indentation, spacing, variable naming, etc)
|
||||
|
||||
Advanced technical competency signals:
|
||||
|
||||
- Compares several coding approaches
|
||||
- Demonstrates strong knowledge of language constructs and paradigms
|
||||
|
||||
| Score | Overall evaluation |
|
||||
| --- | --- |
|
||||
| Strong hire | Demonstrated testing signals effortlessly. |
|
||||
| Leaning hire | Had some difficulty demonstrating testing signals, such as not being able to identify all the relevant corner cases. |
|
||||
| Leaning no hire | Conducted testing but did not handle corner cases. Not able to identify or correct bugs in code. |
|
||||
| Strong no hire | Did not even test code against typical cases. Did not spot glaring bugs in the code and announced they are done |
|
||||
|
||||
### 4. Testing
|
||||
|
||||
Testing signals
|
||||
|
||||
- Came up with more typical cases and tested their code against it
|
||||
- Found and handled corner cases
|
||||
- Identified and self-corrected bugs in code
|
||||
- Able to verify correctness of the code in a systematic manner (e.g. acting like a debugger and stepping through each line, updating the program's state at each step)
|
||||
|
||||
| Score | Overall evaluation |
|
||||
| --- | --- |
|
||||
| Strong hire | Demonstrated testing signals effortlessly. |
|
||||
| Leaning hire | Had some difficulty demonstrating testing signals, such as not being able to identify all the relevant corner cases. |
|
||||
| Leaning no hire | Conducted testing but did not handle corner cases. Not able to identify or correct bugs in code. |
|
||||
| Strong no hire | Did not even test code against typical cases. Did not spot glaring bugs in the code and announced they are done |
|
||||
|
||||
<div className="text--center margin-vert--lg">
|
||||
<figure>
|
||||
<img alt="Coding interview evaluation rubric for software engineers"
|
||||
title="Coding interview evaluation rubric for software engineers" className="shadow--md" src={require('@site/static/img/coding-interview-rubric-software-engineer.jpg').default} style={{maxWidth: 'min(100%, 500px)'}} />
|
||||
<figcaption>Sample coding interview evaluation rubric, for practice</figcaption>
|
||||
</figure>
|
||||
</div>
|
@ -0,0 +1,116 @@
|
||||
---
|
||||
id: coding-interview-study-plan
|
||||
title: Coding interview study plan - what to study and practice based on time left
|
||||
description: Study topics and practice questions based on time left to prepare for Software Engineer coding interviews
|
||||
keywords:
|
||||
[
|
||||
coding interview study plan,
|
||||
what to study for coding interviews,
|
||||
how to prepare for coding interviews,
|
||||
what practice questions to do for coding interviews,
|
||||
how to prepare for coding interviews in 3 months,
|
||||
]
|
||||
sidebar_label: Coding interview study and practice plan
|
||||
---
|
||||
|
||||
import QuestionList from './\_components/QuestionList';
|
||||
|
||||
One of the most important questions to answer at the start of your coding interview preparation is: What study topics and practice questions should you do to most efficiently prepare for your coding interviews?
|
||||
|
||||
There are plenty of resources on the internet, but it can be hard to know how they fit into the time you have left to prepare. Thankfully, this article will help you with that.
|
||||
|
||||
I have personally gone through the dreaded Software Engineer interview process myself several times and prepared my own study plans, refining them each time.
|
||||
|
||||
In this article, I will share the 3 month study plan that I personally use to prepare for my coding interviews. You will find the exact topics to study (with recommended links) and exact questions to practice (with practice links).
|
||||
|
||||
<!--
|
||||
Do check out these links for:
|
||||
What to study and practice if you have 1 month left to coding interviews
|
||||
What to study and practice if you have 1 week left to coding interviews
|
||||
-->
|
||||
|
||||
## Recommended preparation time and approach
|
||||
|
||||
How much time do you need to prepare for your coding interviews? Generally, 3 months (if you can dedicate 11 hours a week) is the recommended period of time for a more holistic preparation. I will be sharing recommended study plans for 3 months (recommended period), but you can generate study plans for practice questions for any time frame you need via the Grind 75 tool (built by me). More options like filtering by difficulty, topics, alternative grouping of questions can be found there.
|
||||
|
||||
Regardless of how long you have, if you are unfamiliar with core data structures and algorithms knowledge, you are advised to revise them before starting on the coding interview questions practice. Different people have different styles of practicing and you should do what works best for you. The various possible approaches are:
|
||||
|
||||
1. **Breadth-first preparation** - Revise every topic and then start practicing a variety of questions across all topics. This strategy is recommended if you have around a month to spare.
|
||||
1. **Depth-first preparation** - Tackle one topic at a time - revise materials for a topic, practice lots of questions for that topic. After ensuring mastery of a topic, move on to the next topic. Repeat for all or selected topics. If you don't have much time, this might be the best way to prepare. You can focus on the High priority topics in our recommended study plan.
|
||||
1. **Depth-first-then-breadth preparation** - Tackle one topic at a time - revise materials for a topic, practice a few questions for that topic. After ensuring mastery, move on to the next topic. Repeat for all topics. At the end, practice a variety of questions across all topics. This strategy takes more time than others, so it's recommended if you have more than a month.
|
||||
|
||||
My personal recommendation would be the **Breadth-first preparation** or **Depth-first-then-breadth preparation**. It's important to have some form of breadth-level studying / practicing in your schedule so that you don't forget about the earlier topics as you move on to later topics.
|
||||
|
||||
## The 3 month study plan - with recommended study resources and practice question links
|
||||
|
||||
In each study plan, you will find a list of coding interview topics with resources and practice questions that you should work through **in order of priority** every week.
|
||||
|
||||
To best utilize it, you should create a template where you break down the dates left and hours left per day, so that you can later fill in the topics/questions to cover per day.
|
||||
|
||||
Keep the estimate relatively conservative so you don't end up burning out.
|
||||
|
||||
### Week 1 - 4: Topical study + practice
|
||||
|
||||
These are all the topics you should study, in order of priority. The learning resources linked are my algorithm cheatsheets - which give you an overview of must-remembers like time complexity, corner cases and topic-specific useful techniques, as well as must-do practice questions.
|
||||
|
||||
Don't forget to apply behaviors from [coding interview best practices](./coding-interview-best-practices.md) and methods from [coding interview techniques](./coding-interview-techniques.md) early on while you practice!
|
||||
|
||||
#### Week 1
|
||||
|
||||
| Topic | Priority | Time required |
|
||||
| ---------------------------------------- | -------- | ------------- |
|
||||
| [Array](./algorithms/array.md) | High | 2 hours |
|
||||
| [String](./algorithms/string.md) | High | 3 hours |
|
||||
| [Hash Table](./algorithms/hash-table.md) | Mid | 3 hours |
|
||||
| [Recursion](./algorithms/recursion.md) | Mid | 3 hours |
|
||||
|
||||
#### Week 2
|
||||
|
||||
| Topic | Priority | Time required |
|
||||
| --- | --- | --- |
|
||||
| [Sorting and searching](./algorithms/sorting-searching.md) | High | 3 hours |
|
||||
| [Matrix](./algorithms/matrix.md) | High | 1 hour |
|
||||
| [Linked List](./algorithms/linked-list.md) | Mid | 3 hours |
|
||||
| [Queue](./algorithms/queue.md) | Mid | 2 hours |
|
||||
| [Stack](./algorithms/stack.md) | Mid | 2 hours |
|
||||
|
||||
#### Week 3
|
||||
|
||||
| Topic | Priority | Time required |
|
||||
| ------------------------------ | -------- | ------------- |
|
||||
| [Tree](./algorithms/tree.md) | High | 4 hours |
|
||||
| [Graph](./algorithms/graph.md) | High | 4 hours |
|
||||
| [Heap](./algorithms/heap.md) | Mid | 3 hours |
|
||||
| [Trie](./algorithms/trie.md) | Mid | 3 hours |
|
||||
|
||||
#### Week 4
|
||||
|
||||
| Topic | Priority | Time required |
|
||||
| --- | --- | --- |
|
||||
| [Interval](./algorithms/interval.md) | Mid | 2 hours |
|
||||
| [Dynamic programming](./algorithms/dynamic-programming.md) | Low | 4 hours |
|
||||
| [Binary](./algorithms/binary.md) | Low | 2 hours |
|
||||
| [Math](./algorithms/math.md) | Low | 1 hour |
|
||||
| [Geometry](./algorithms/geometry.md) | Low | 1 hour |
|
||||
|
||||
### Week 5 - 12: In-depth practice
|
||||
|
||||
Here, I listed 75 questions that you should do to be fully prepared for your coding interviews. This list of questions are generated from the [**Grind 75 tool**](https://www.techinterviewhandbook.org/grind75/) (built by me), which generates recommended study plans for coding interviews based on the time you have left. More options like filtering by difficulty, topics, alternative grouping of questions can be found there.
|
||||
|
||||
Feel free to skip the dynamic programming questions if you haven't studied them or feel that they won't be relevant. Many dynamic programming questions can be solved with recursion / backtracking anyway.
|
||||
|
||||
Don't forget to apply behaviors from [coding interview best practices](./coding-interview-best-practices.md) and methods from [coding interview techniques](./coding-interview-techniques.md) early on while you practice!
|
||||
|
||||
<QuestionList />
|
||||
|
||||
## Factor time for your self introduction, final questions and mock coding interviews
|
||||
|
||||
Besides studying and practicing for coding interviews, you should also prepare your self introduction, final questions, and try out mock coding interviews.
|
||||
|
||||
### Prepare self introduction and final questions to ask
|
||||
|
||||
I would suggest around 3 hours to craft your self introduction and also prepare some final questions to ask. You may refer to this [self introduction guide](./self-introduction.md) and [final questions to ask guide](./final-questions.md) which should help you complete these steps fairly quickly.
|
||||
|
||||
### Schedule mock coding interviews
|
||||
|
||||
You should start scheduling for mock coding interviews when you are 60% through your coding interview studying and practicing plan. Interview slots are typically provided by interviewers, so you can view them in advance and book them. The platform I have personally used and recommend is [interviewing.io](https://iio.sh/r/DMCa). Read more about [different mock coding interview platforms here](./mock-interviews.md).
|
@ -0,0 +1,237 @@
|
||||
---
|
||||
id: coding-interview-techniques
|
||||
title: Top techniques to approach and solve coding interview questions
|
||||
description: Learn methods to find solutions for coding interview problems and optimize their time and space complexity
|
||||
keywords:
|
||||
[
|
||||
how to approach a coding interview question,
|
||||
how to solve any coding interview question,
|
||||
coding interview practice,
|
||||
coding interview questions,
|
||||
optimize time complexity,
|
||||
optimize space complexity,
|
||||
optimize time and space complexity,
|
||||
]
|
||||
sidebar_label: Techniques to solve coding interview questions
|
||||
---
|
||||
|
||||
The biggest fear most candidates will have during a coding interview is: what if I get stuck on the question and don't know how to do it? Fortunately, there are structured ways to approach coding interview questions that will increase your chances of solving them. From how to find a solution or approach, to optimizing time and space complexity, here are some of the top tips and best practices that will help you solve coding interview questions.
|
||||
|
||||
## How to find solutions to coding interview problems
|
||||
|
||||
When given a coding interview question, candidates should start by asking clarifying questions and discussing a few possible approaches with their interviewers. However, this is where most candidates tend to get stuck. Thankfully, there are ways to do this in a structured manner.
|
||||
|
||||
Note that not all techniques will apply to every coding interview problem. As you apply these techniques during your practice, you will develop the intuition for which technique will be useful for the problem at hand.
|
||||
|
||||
### 1. Visualize the problem by drawing it out
|
||||
|
||||
Ever wondered why coding interviews are traditionally done on whiteboards and videos explaining answers to coding questions tend to use diagrams? Whiteboards make it easy to draw diagrams which helps with problem solving! A huge part of coding is understanding how the internal state of a program changes and diagrams are super useful tools for representing the internal data structures state. If you are having a hard time understanding how the solution is obtained, come up with a visual representation of the problem and if necessary, the internal states at each step.
|
||||
|
||||
This technique is especially useful if the input involves trees, graphs, matrices, linked lists.
|
||||
|
||||
#### Example
|
||||
|
||||
How would you [return all elements of a matrix in spiral order](https://leetcode.com/problems/spiral-matrix/)? Drawing out the matrix and the path your iterator needs to take will help tremendously by allowing you to see the pattern.
|
||||
|
||||
### 2. Think about how you would solve the problem by hand
|
||||
|
||||
Solving the problem by hand is about solving the problem without writing any code, like how a non-programmer would. This already happens naturally most of the time when you are trying to understand the example given to you.
|
||||
|
||||
What some people don't realize is that sometimes a working solution is simply a code version of the manual approach. If you can come up with a concrete set of rules around the approach that works for every example, you can write the code for it. While you might not arrive at the most efficient solution by doing this, it's a start which will give you some credit.
|
||||
|
||||
#### Example
|
||||
|
||||
How do you [validate if a tree is a valid Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/) without writing any code? You first check if the left subtree contains only values less than the root, then check that the right subtree contains only values bigger than the root, then repeat for each node. This process seems feasible. Now you just have to turn this process into code.
|
||||
|
||||
### 3. Come up with more examples
|
||||
|
||||
Coming up with more examples is something useful you can do regardless of whether you are stuck or not. It helps you to reinforce your understanding of the question, prevents you from prematurely jumping into coding, and having multiple examples is helpful when verifying your solution later. Coming up with more examples and then solving them by hand also helps you to identify a pattern which can be generalized to any input, which is the solution!
|
||||
|
||||
### 4. Break the question down into smaller independent parts
|
||||
|
||||
If the problem is large, start with a high-level function and break it down into smaller constituting functions, solving each one separately. This prevents you from getting overwhelmed with the details of doing everything at once and keeps your thinking structured.
|
||||
|
||||
Doing so also makes it clear to the interviewer that you have an approach, even if you don't manage to finish coding all of the smaller functions.
|
||||
|
||||
#### Example
|
||||
|
||||
The [Group Anagrams](https://leetcode.com/problems/group-anagrams/) problem can be broken down into two parts - hashing a string, grouping the strings together. Each part can be solved separately with independent implementation details. You could start off with this code:
|
||||
|
||||
```py
|
||||
def group_anagrams(strings):
|
||||
def hash(string):
|
||||
pass
|
||||
|
||||
def group_strings(strings_hashes):
|
||||
pass
|
||||
|
||||
strings_hashes = [(string, hash(string)) for string in strings]
|
||||
return group_strings(strings_hashes)
|
||||
```
|
||||
|
||||
And proceed to fill in the implementation of each function. However, do note that sometimes the most efficient solutions will require you to break some abstractions and do multiple operations in one pass of the input. If your interviewer asks you to optimize based on your well-abstracted solution, that is one possible path forward.
|
||||
|
||||
### 5. Apply common data structures and algorithms at the problem
|
||||
|
||||
Unlike real-world software engineering where the problems are usually open-ended and might not have clear solutions, coding interview problems tend to be smaller in nature and are designed to be solvable within the duration of the interview. You can also expect that the knowledge required to solve the problem is not out of this world and they would have been taught during college. Thankfully, the number of common data structures and algorithms is finite and a hacky approach which works from my experience is to try going through all the common data structures and applying them to the problem.
|
||||
|
||||
These are the data structures to keep in mind and try, in order of frequency they appear in coding interview questions:
|
||||
|
||||
- Hash Maps - Useful for making lookup efficient. This is the most common data structure used in interviews and you are guaranteed to have to use it
|
||||
- Graphs - If the data is presented to you as associations between entities, you might be able to model the question as a graph and use some common graph algorithm to solve the problem
|
||||
- Stack and Queue
|
||||
- Heap - Question involves scheduling/ordering based on some priority. Also useful for finding the max K/min K/median elements in a set
|
||||
- Tree/Trie - Do you need to store strings in a space-efficient manner and look for the existence of strings (or at least part of them) very quickly?
|
||||
|
||||
**Routines**
|
||||
|
||||
- Sorting
|
||||
- Binary search - Useful if the input array is sorted and you need to do faster than O(n) searches
|
||||
- Sliding window
|
||||
- Two pointers
|
||||
- Union find
|
||||
- BFS/DFS
|
||||
- Traverse from the back
|
||||
- Topological Sorting
|
||||
|
||||
In future we will add tips on how to better identify the most relevant data structures and routines based on the problem.
|
||||
|
||||
## How to optimize your approach or solution
|
||||
|
||||
After you've come up with an initial solution to the coding interview problem, your interviewer would most likely prompt you to optimize the solution by asking "Can we do better". The following techniques help you further optimize the time and space complexity of your solution:
|
||||
|
||||
### How to optimize time complexity
|
||||
|
||||
#### 1. Identify the Best Theoretical Time Complexity of the solution
|
||||
|
||||
The Best Theoretical Time Complexity (BTTC) of a solution is a time complexity you know that you cannot beat.
|
||||
|
||||
Some simplified examples:
|
||||
|
||||
- The BTTC of finding the sum of numbers in array is O(n) because you have to look at every value in the array at least once
|
||||
- The BTTC of finding the [number of groups of anagrams](https://leetcode.com/problems/group-anagrams/) is O(nk) where n is the number of words and k is the maximum number of letters in a word because you have to look at each word at least once and look at each character in each word at least once
|
||||
- The BTTC of finding the number of islands in a matrix is O(nm) where n is the number of rows and m is the number of columns because you have to look at each cell in the matrix at least once
|
||||
|
||||
Why is it important to know the BTTC? So that you don't go down the rabbit hole of trying to find a solution that is faster than the BTTC. The fastest practical solution can only ever be as fast as the BTTC, not faster than the BTTC. The BTTC is not necessarily achievable in practice (hence theoretical), it just means you can never find a real solution that is faster than it. If your initial solution is slower than the BTTC, there could be opportunities to improve such that you can attain the BTTC (but not always the case). It wouldn't hurt to mention the BTTC to your interviewer, which will be taken as a positive signal and also to remind yourself that you should not try to come up with something faster than the BTTC.
|
||||
|
||||
Some people might think that the BTTC is simply the total number of elements in a data structure, because you need to go through each element once. This is **not always true**. The most famous example would be finding a number in a sorted array of numbers. The sorted property changes things a whole lot:
|
||||
|
||||
- Finding a number would be O(log(n)) because you can use a binary search.
|
||||
- Finding the largest number would be O(1) because it is the last value in the array.
|
||||
|
||||
This is why it is important to pay attention to every detail given about the question. Be careful not to determine the incorrect BTTC due to lack of attention to the question details!
|
||||
|
||||
With the correct BTTC determined, you now know the time complexity of the optimal solution lies between your initial solution and the BTTC and can work your way towards it. If your solution already has the BTTC and the interviewer is asking you to optimize further, there are usually two things they are looking out for:
|
||||
|
||||
- Do even less work. Your solution could be O(n) but making two passes of the array and the interviewer is looking for the solution that uses a single pass.
|
||||
- Use less space. Refer to the section below on optimizing space complexity.
|
||||
|
||||
#### 2. Identify overlapping and repeated computation
|
||||
|
||||
A naive/brute force solution often executes the same operation over and over again. When the code is doing an expensive operation that has been done before, take a moment to step back and consider if you can reuse results from previous computations. Dynamic programming (DP) is the most obvious type of questions you can entirely leverage past computations. There are non-DP questions that can leverage this technique too, although not as straightforward and might require a preprocessing step.
|
||||
|
||||
##### Example
|
||||
|
||||
The [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/) question is a good example of a problem which contains overlapping/repeated work. To get the value for an index, you need to multiply the values at all other positions. Doing this for every value in the array would take O(n<sup>2</sup>) time. However, see that:
|
||||
|
||||
- `result[n]`: `Product(nums[0] … nums[n-1]) * Product(nums[n + 1] … nums[N - 1])`
|
||||
- `result[n + 1]`: `Product(nums[0] … nums[n]) * Product(num[n + 2] … nums[N - 1])`
|
||||
|
||||
There's a ton of duplicated work in computing the `result[n]` vs `result[n + 1]`! This is an opportunity to reuse earlier computations made while computing `result[n]` to compute `result[n + 1]`. Indeed, we can make use of a prefix array to help us arrive at the final solution in O(n) time at the cost of more space.
|
||||
|
||||
#### 3. Try different data structures
|
||||
|
||||
Choice of data structures is key to coding interviews. It can help you to reach a solution for the problem, it can also help you to optimize your existing solution. Sometimes it's worth going through the exercise of iterating through the data structures you know once again.
|
||||
|
||||
Is lookup time slowing your algorithm down? In general, most lookup operations should be O(1) with the help of a hashmap. If the lookup operation in your solution is the bottleneck to your solution's time complexity, more often than not, you can use a hashmap to optimize the lookup.
|
||||
|
||||
##### Example
|
||||
|
||||
The [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin/) question can be solved in a naive manner by calculating the distance of each point, sorting them and then taking the K smallest values. This takes O(nlog(n)) time because of the sorting. However, by using a Heap data structure, the time complexity can be reduced to O(nlog(k)) as adding/removing from the heap only takes O(log(k)) time when the size of the heap is capped at K elements. Changing the data structure made a whole ton of difference to the efficiency of the algorithm!
|
||||
|
||||
#### 4. Identify redundant work
|
||||
|
||||
Here are a few examples of code which is doing redundant work. Although making these mistakes might not change the overall time complexity of your code, you are also evaluated on coding abilities, so it is important to write as efficient code as possible.
|
||||
|
||||
##### Example
|
||||
|
||||
<!-- TODO elaborate on examples -->
|
||||
|
||||
Don't check conditions unnecessarily. These are examples where the second check is redundant.
|
||||
|
||||
- `if not arr and len(arr) == 0`
|
||||
- `x < 5 and x < 10`
|
||||
|
||||
Don't invoke methods unnecessarily
|
||||
|
||||
- `len(arr)` in many parts of the function. If the len doesn't change, declare a variable at the start
|
||||
|
||||
Minimize work inside loops / Don't redo work you have already done
|
||||
|
||||
- Transforming a string within a for loop. Transform the string outside the for loop!
|
||||
|
||||
Be lazy. Use lazy evaluation - only evaluate expressions when you need it
|
||||
|
||||
- `slow() or fast()`
|
||||
- `likely() and unlikely()`
|
||||
|
||||
Lazy initialization - only create objects when you know you're going to need them
|
||||
|
||||
Do early termination. Stop after you already know the answer.
|
||||
|
||||
Consider this basic question "Determine if an array contains an even number" and the code for it:
|
||||
|
||||
```py
|
||||
def has_even(nums):
|
||||
has_even = False
|
||||
for num in nums:
|
||||
if num % 2 == 0:
|
||||
has_even = True
|
||||
return has_even
|
||||
```
|
||||
|
||||
Does this code work? Definitely. Is this code as efficient as it can be? Nope. We only need to know if an even value exists in the array. We can stop iterating as soon as we know that there exists an even value.
|
||||
|
||||
```py
|
||||
def has_even(nums):
|
||||
for num in nums:
|
||||
if num % 2 == 0:
|
||||
return True
|
||||
return False
|
||||
```
|
||||
|
||||
Most people already know this and already do this outside of an interview. However, in a stressful interview environment, people tend to forget the most obvious things. Terminate early from loops where you can.
|
||||
|
||||
### How to optimize space complexity
|
||||
|
||||
Most of the time, time complexity is more important than space complexity. But when you have already reached the optimal time complexity, the interviewer might ask you to optimize the space your solution is using (if it is using extra space). Here are some techniques you can use to improve the space complexity of your code.
|
||||
|
||||
#### 1. Changing data in-place/overwriting input data
|
||||
|
||||
If your solution contains code to create new data structures to do intermediate processing/caching, memory space is being allocated and can sometimes be seen as a negative. A trick to get around this is by overwriting values in the original input array so that you are not allocating any new space in your code. However, be careful not to destroy the input data in irreversible ways if you need to use it in subsequent parts of your code.
|
||||
|
||||
A possible way which works (but you should never use outside of coding interviews) is to mutate the original array and use it as a hashmap to store intermediate data. Refer to the example below.
|
||||
|
||||
Note that in Software Engineering, mutating input data is generally frowned upon and makes your code harder to read and maintain, so changing data in-place is mostly something you should do only in coding interviews.
|
||||
|
||||
#### Example
|
||||
|
||||
The [Dutch National Flag](https://leetcode.com/problems/sort-colors/) problem could be easily solved with O(n) time and O(n) space by creating a new array and filling it up with the respective values in a sorted fashion. As an added challenge and space optimization, the interviewer will usually ask for an O(n) time and O(1) space solution which involves sorting the input array in-place.
|
||||
|
||||
An example of using the original array as a hash table is the [First Missing Positive](https://leetcode.com/problems/first-missing-positive) question. After the first for loop, all the values in the array are positive, and you can indicate presence of a number by negating the value at the index corresponding to the number. To indicate 4 is present, negate `nums[4]`.
|
||||
|
||||
#### 2. Change a data structure
|
||||
|
||||
Data structures again!? Yes, data structures again! Data structures are so fundamental to coding interviews and mastery of it makes or breaks your interview performance. Are you using the best data structure possible for the problem?
|
||||
|
||||
#### Example
|
||||
|
||||
You're given a list of strings and want to find how many of these strings start with a certain prefix. What's an efficient way to store the strings so that you can compute your answer quickly? A [Trie](https://leetcode.com/problems/implement-trie-prefix-tree/) is a tree-like data structure that is very efficient for storing strings and also allows you to quickly compute how many strings start with a prefix.
|
||||
|
||||
## Next Steps
|
||||
|
||||
If you haven't already, I recommend you check out my [free structured guide for coding interviews](./software-engineering-interview-guide.md), which contains step by step guidance such as:
|
||||
|
||||
- [How to make an efficient plan for your coding interview preparation](./coding-interview-study-plan.md) - including priority of topics and questions to study, based on the time you have left
|
||||
- [Coding interview best practices cheatsheet](./coding-interview-best-practices.md) - including how to behave during a coding interview to exhibit hire signals
|
||||
- [Algorithms cheatsheets](.//algorithms/study-cheatsheet.md) - including the must-remembers that you should internalize for every data structure
|
@ -0,0 +1,63 @@
|
||||
---
|
||||
id: final-questions
|
||||
title: 'Software Engineer interviews: Best end of interview questions to ask'
|
||||
description: The best questions to ask the interviewer at the end of a Software Engineer interview to leave a good impression
|
||||
keywords:
|
||||
[
|
||||
questions to ask at the end of an interview software engineer,
|
||||
questions to ask software engineer interview,
|
||||
software engineer questions to ask interviewer,
|
||||
software engineer interview questions to ask,
|
||||
]
|
||||
---
|
||||
|
||||
Something you can always count on to happen at the end of your Software Engineer interview - both technical and non-technical rounds - is for the interviewer to ask you if you "have any final questions?".
|
||||
|
||||
This question actually isn't a real question at all - candidates are generally expected to ask questions. As an interviewer myself, candidates who don't have any questions might come off as less interested in the role.
|
||||
|
||||
Besides that, the questions you ask reveal what you care about. If asked well, this can be a very predictable opportunity for you to leave a good impression while also knowing more about the role (including uncovering potential red flags).
|
||||
|
||||
Here, I present questions to ask at the end of your software engineer interviews, for every purpose:
|
||||
|
||||
## Best questions to ask for knowing more about technical work
|
||||
|
||||
- What is the most costly technical decision made early on that the company is living with now?
|
||||
- What is the most fulfilling / exciting / technically complex project that you've worked on here so far?
|
||||
- What has been the worst technical blunder that has happened in the recent past? How did you guys deal with it? What changes were implemented afterwards to make sure it didn't happen again?
|
||||
- What is your stack? What is the rationale for/story behind this specific stack?
|
||||
- Does your team use Agile or Waterfall dev methodology and why?
|
||||
|
||||
## Best questions to ask for knowing more about the role
|
||||
|
||||
- What qualities do you look out for when hiring for this role?
|
||||
- What concerns / reservations do you have about me for this position?
|
||||
- What does a typical day look like in this role?
|
||||
- What would be the most important problem you would want me to solve if I joined your team?
|
||||
- What are the strengths and weaknesses of the current team? What is being done to improve upon the weaknesses?
|
||||
- What resources does the company have for new hires to study its product and processes? Are there specifications, requirements, documentation?
|
||||
- What would I work on if I joined this team and who would I work most closely with?
|
||||
|
||||
## Best questions to ask for knowing more culture and welfare
|
||||
|
||||
- How is individual performance measured?
|
||||
- What is the current team composition like?
|
||||
- What do you like about working here?
|
||||
- What is the most frustrating part about working here?
|
||||
- What is unique about working at this company that you have not experienced elsewhere?
|
||||
- What is your policy on working from home/remotely?
|
||||
- What does the company do to nurture and train its employees?
|
||||
- Does the company culture encourage entrepreneurship and creativity? Could you give me any specific examples?
|
||||
|
||||
## Best questions to ask to know more about team leadership or management
|
||||
|
||||
- How do you train/ramp up engineers who are new to the team?
|
||||
- What is your management philosophy?
|
||||
- How do you measure individual performance?
|
||||
- How do your engineers know what to work on each day?
|
||||
- What is your team's biggest challenge right now?
|
||||
- Have you managed a poor performer at some point in your career before? What did you do and how did it work?
|
||||
|
||||
## Best questions to ask to know more about company direction
|
||||
|
||||
- What assurance do you have that this company will be successful?
|
||||
- How does the company decide on what to work on next?
|
@ -1,23 +1,31 @@
|
||||
---
|
||||
id: mock-interviews
|
||||
title: Mock interviews
|
||||
title: Best mock coding interview platforms for Software Engineers
|
||||
description: Review of top mock interview platforms for Software Engineer coding interviews
|
||||
keywords:
|
||||
[
|
||||
mock interview,
|
||||
best mock interview platforms,
|
||||
best mock coding interview platforms,
|
||||
best sites to use for mock coding interviews,
|
||||
interviewing.io review,
|
||||
pramp review,
|
||||
coding mock interview,
|
||||
mock tech interview,
|
||||
]
|
||||
sidebar_label: Mock coding interviews
|
||||
---
|
||||
|
||||
<head>
|
||||
<title>Improve your technical interviewing skills through mock interviews | Tech Interview Handbook</title>
|
||||
<meta property="og:title" content="Improve your technical interviewing skills through mock interviews | Tech Interview Handbook"/>
|
||||
</head>
|
||||
|
||||
Interviewing is a skill that you can get better at. The steps mentioned above can be rehearsed over and over again until you have fully internalized them and following those steps become second nature to you. A good way to practice is to find a friend to partner with and the both of you can take turns to interview each other.
|
||||
|
||||
## interviewing.io
|
||||
## [interviewing.io](https://iio.sh/r/DMCa)
|
||||
|
||||
A great resource for practicing mock coding interviews would be [interviewing.io](https://iio.sh/r/DMCa). interviewing.io provides anonymous practice technical interviews with Google and Facebook engineers, which can lead to real jobs and internships. By virtue of being anonymous during the interview, the inclusive interview process is de-biased and low risk. At the end of the interview, both interviewer and interviewees can provide feedback to each other for the purpose of improvement. Doing well in your mock interviews will unlock the jobs page and allow candidates to book interviews (also anonymously) with top companies like Uber, Lyft, Quora, Asana and more. You can also book mock interviews for more specific roles such as Mobile, Front End, Engineering Management. For those who are totally new to technical interviews, you can even view [recorded interviews](https://interviewing.io/recordings) and see how phone interviews are like. Read more about them [here](https://techcrunch.com/2017/09/27/interviewing-io-hopes-to-close-the-engineer-diversity-gap-with-anonymous-interviews/).
|
||||
A great resource for practicing mock coding interviews would be [interviewing.io](https://iio.sh/r/DMCa). [interviewing.io](https://iio.sh/r/DMCa) provides anonymous practice technical interviews with Google and Facebook engineers, which can lead to real jobs and internships. By virtue of being anonymous during the interview, the inclusive interview process is de-biased and low risk. At the end of the interview, both interviewer and interviewees can provide feedback to each other for the purpose of improvement. Doing well in your mock interviews will unlock the jobs page and allow candidates to book interviews (also anonymously) with top companies like Uber, Lyft, Quora, Asana and more. You can also book mock interviews for more specific roles such as Mobile, Front End, Engineering Management. For those who are totally new to technical interviews, you can even view [recorded interviews](https://interviewing.io/recordings) and see how phone interviews are like. Read more about them [here](https://techcrunch.com/2017/09/27/interviewing-io-hopes-to-close-the-engineer-diversity-gap-with-anonymous-interviews/).
|
||||
|
||||
I have used interviewing.io both as an interviewer and an interviewee and found the experience to be really great! [Aline Lerner](https://twitter.com/alinelernerLLC), the CEO and co-founder of interviewing.io and her team are passionate about revolutionizing the technical interview process and helping candidates to improve their skills at interviewing. She has also published a number of technical interview-related articles on the [interviewing.io blog](http://blog.interviewing.io/).
|
||||
I have used [interviewing.io](https://iio.sh/r/DMCa) both as an interviewer and an interviewee and found the experience to be really great! [Aline Lerner](https://twitter.com/alinelernerLLC), the CEO and co-founder of [interviewing.io](https://iio.sh/r/DMCa) and her team are passionate about revolutionizing the technical interview process and helping candidates to improve their skills at interviewing. She has also published a number of technical interview-related articles on the [interviewing.io blog](http://blog.interviewing.io/).
|
||||
|
||||
## Pramp
|
||||
|
||||
Another platform that allows you to practice coding interviews is [Pramp](https://pramp.com/). Where interviewing.io matches potential job seekers with seasoned technical interviewers, Pramp takes a different approach. Pramp pairs you up with another peer who is also a job seeker and both of you take turns to assume the role of interviewer and interviewee. Pramp also prepares questions for you, along with suggested solutions and prompts to guide the interviewee.
|
||||
Another platform that allows you to practice coding interviews is [Pramp](https://pramp.com). Where [interviewing.io](https://iio.sh/r/DMCa) matches potential job seekers with seasoned technical interviewers, Pramp takes a different approach. Pramp pairs you up with another peer who is also a job seeker and both of you take turns to assume the role of interviewer and interviewee. Pramp also prepares questions for you, along with suggested solutions and prompts to guide the interviewee.
|
||||
|
||||
Personally, I am not that fond of Pramp's approach because if I were to interview someone, I would rather choose a question I am familiar with. Also, many users of the platform do not have the experience of being interviewers and that can result in a horrible interview experience. There was once where my matched peer, as the interviewer, did not have the right understanding of the question and attempted to lead me down the wrong path of solving the question. However, this is more of a problem of the candidate than the platform though.
|
||||
|
@ -0,0 +1,64 @@
|
||||
---
|
||||
id: programming-languages-for-coding-interviews
|
||||
title: Which programming language to use for coding interviews
|
||||
description: Considerations for deciding which programming language to use for coding interviews
|
||||
keywords:
|
||||
[
|
||||
coding interview programming language,
|
||||
which programming language should i use for coding interviews,
|
||||
python coding interviews,
|
||||
java coding interviews,
|
||||
c# coding interviews,
|
||||
javascript coding interviews,
|
||||
]
|
||||
sidebar_label: Picking a programming language
|
||||
---
|
||||
|
||||
Does the programming language you use for coding interviews matter? The answer is yes.
|
||||
|
||||
Most languages let you code in any language you want - the only exception I know being Google, where they only allow candidates to pick from Java, C++, JavaScript or Python for their algorithmic coding interviews.
|
||||
|
||||
However, the choice you make can impact your performance much more than you'd like to believe - and this is why it is important to pick a suitable programming language early on in your coding interview preparation - and use regularly in practice.
|
||||
|
||||
There are 3 considerations when deciding on which programming language to use:
|
||||
|
||||
1. Suitability for interviews
|
||||
1. Your familiarity with the language
|
||||
1. Exceptions
|
||||
|
||||
## 1. Suitability for interviews
|
||||
|
||||
Some languages are just more suited for interviews - higher level languages like Python or Java provide standard library functions and data structures which allow you to translate solution to code more easily.
|
||||
|
||||
From my experience as an interviewer, most candidates pick Python or Java. Other commonly seen languages include JavaScript, Ruby and C++. I would absolutely avoid lower level languages like C or Go, simply because they lack many standard library functions and data structures and some may require manual memory management.
|
||||
|
||||
Personally, Python is my de facto choice for algorithm coding interviews because it is succinct and has a huge library of functions and data structures available. Python also uses consistent APIs that operate on different data structures, such as `len()`, `for ... in ...` and slicing notation on sequences (strings/lists/tuples). Getting the last element in a sequence is `arr[-1]` and reversing it is simply `arr[::-1]`. You can achieve a lot with minimal syntax in Python.
|
||||
|
||||
Java is a decent choice too but having to constantly declare types in your code means extra keystrokes which results in more typing which doesn't result in any benefit (in an interview setting). This issue will be more apparent when you have to write on a whiteboard during onsite interviews. The reasons for choosing/not choosing C++ are similar to Java. Ultimately, Python, Java and C++ are decent choices of languages.
|
||||
|
||||
- Recommended: Python, C++, Java, JavaScript
|
||||
- Acceptable (but prefer recommended if you are familiar): Go, Ruby, PHP, C#, Swift, Kotlin
|
||||
- Avoid: Haskell, Erlang, Perl, C, Matlab
|
||||
- You must be mad: Brainfuck, Assembly
|
||||
|
||||
## 2. Your familiarity with the language
|
||||
|
||||
Most of the time, it is recommended that you use a language that you are extremely familiar with rather than picking up a new language just for using in interviews.
|
||||
|
||||
If you are under time constraints, picking up a new language just for interviewing is hardly a good idea. Languages take time to master and if you are already spending most of your time and effort on revising/mastering algorithms, there is barely spare energy left for mastering a new language. If you are familiar with using one of the mainstream languages, there isn't a strong reason to learn a new language just for interviewing.
|
||||
|
||||
If you have been using Java at work for a while now and do not have time to be comfortably familiar with another language, I would recommend just sticking to Java instead of picking up Python from scratch just for the sake of interviews. Doing so, you can avoid having to context switch between languages during work vs interviews. **Most of the time, the bottleneck is in the thinking and not the writing**. It takes some getting used to before one becomes fluent in a language and be able to wield it with ease.
|
||||
|
||||
Valid reasons to learn a new language:
|
||||
|
||||
- The interview requires usage of that language (domain-specific roles like mobile/front end/data science)
|
||||
- You are not in a rush to start interviewing
|
||||
|
||||
Poor reasons to learn a new language:
|
||||
|
||||
- The company you are interviewing with uses that language heavily and you want to impress the interviewer/show that you fit in
|
||||
- You want to show that you are trendy
|
||||
|
||||
## 3. Exceptions
|
||||
|
||||
One exception to the convention of allowing you to "pick any programming language you want" is when you are interviewing for a domain-specific position, such as Front End/iOS/Android Engineer roles, in which you would need to be familiar with coding in JavaScript, Objective-C/Swift and Java respectively. If you need to use a data structure that the language does not support, such as a Queue or Heap in JavaScript, perhaps try asking the interviewer whether you can assume that you have a data structure that implements certain methods with specified time complexities. If the implementation of that data structure is not crucial to solving the problem, the interviewer will usually allow this. In reality, being aware of existing data structures and selecting the appropriate ones to tackle the problem at hand is more important than knowing the intricate implementation details.
|
@ -0,0 +1,215 @@
|
||||
---
|
||||
id: software-engineering-interview-guide
|
||||
title: 'Software Engineer interviews: Everything you need to prepare'
|
||||
description: What to expect, how to prepare and how to excel in Software Engineering interviews
|
||||
keywords:
|
||||
[
|
||||
software engineer interview preparation,
|
||||
technical interview preparation,
|
||||
how to prepare for your software engineer interview,
|
||||
software developer interview,
|
||||
coding interview preparation,
|
||||
best leetcode questions,
|
||||
coding interview questions,
|
||||
software engineering interview questions,
|
||||
]
|
||||
sidebar_label: 'SWE interviews: What are they and how to prepare'
|
||||
---
|
||||
|
||||
Nobody has time to grind hundreds of LeetCode questions, and the good news is that you don't need to do that many to actually get the job at FAANG!
|
||||
|
||||
I was frustrated at my job at Grab, a ridesharing company in South-east Asia and wanted to break into FAANG but I wasn't sure how to. After a few months of research, studying and practicing, I interviewed at 11 companies and managed to get 9 offers from top tech companies in the Bay Area - Facebook, Google, Airbnb, Palantir, Dropbox, Lyft, and some startups. It was a tedious process which I don't ever want to go through again. **I went through that process but with this guide, you don't have to.**
|
||||
|
||||
This guide will provide a **quick overview of the top tips on how to prepare for a software engineer interview** - both technical and non-technical interview rounds. Where relevant, you can delve into greater detail by accessing links in this overview article, or through the website's left sidebar.
|
||||
|
||||
How to prepare for your software engineering interview:
|
||||
|
||||
1. Maximize your chances of being shortlisted
|
||||
1. Find out the interview format
|
||||
1. Pick a programming language
|
||||
1. Sharpen your Computer Science fundamentals for interviews
|
||||
1. Practice for the coding interview
|
||||
1. Prepare for the systems design interview (for mid/senior levels)
|
||||
1. Prepare for the behavioral interview
|
||||
1. Negotiating the offer package
|
||||
|
||||
## Maximize your chances of being shortlisted
|
||||
|
||||
Do you still have trouble getting shortlisted at some or all of the top tech companies? Your resume could be the issue.
|
||||
|
||||
Your resume is the single most important entry point to getting shortlisted in major tech companies like FAANG / MANGA. After getting shortlisted, your past achievements become markedly less important as compared to your coding interview skills - which as we know, can be methodically learnt. Being able to frame your past achievements well enough to get through the screening stage is hence very important.
|
||||
|
||||
Unfortunately, even the most qualified candidates I know personally don't know how to write a good resume and fail to get shortlisted. The truth is that when many of us don't get shortlisted at top tech companies like FAANG / MANGA, we tend to think that we were under-qualified - but in most cases, it's probably just the lack of good framing.
|
||||
|
||||
If you want to learn how to write a good software engineer resume, I've written a [step-by-step guide here on software engineering resume preparation](./resume.md) for companies like Google, Facebook, Amazon, Netflix, Apple, with examples for your reference as well.
|
||||
|
||||
## Find out the interview format
|
||||
|
||||
You may encounter various interview formats in your software engineer interviews (from early to late stage):
|
||||
|
||||
### 1. Quiz
|
||||
|
||||
Frequency: Occasional
|
||||
|
||||
Quizzes are meant to be a first-pass filter as a quick and dirty way of weeding out extremely weak (or even non-technical) candidates. They are structured questions and have clear-cut answers which makes them possible to be administered by recruiters/non-technical folks or automated graders. They are typically done early in the process.
|
||||
|
||||
Examples:
|
||||
|
||||
- What is 4 & 5 (in binary)? Answer: 4
|
||||
- What is the time complexity of bubble sort? Answer: O(n<sup>2</sup>)
|
||||
|
||||
### 2. Online coding assessment
|
||||
|
||||
Frequency: Occasional
|
||||
|
||||
Like quizzes, online coding assessments are usually given early in the process. An algorithm problem is given with well-formed input and output and candidates are expected to write code in an online coding interface to solve the problem. [HackerRank](https://www.hackerrank.com) is a very common platform for conducting online coding assessments. LeetCode would be a good way to practice for the problem solving aspects of online coding assessments. However, in HackerRank you are typically expected to write code to read from stdin and also print to stdout, which can trip candidates up if they aren't familiar with the APIs.
|
||||
|
||||
### 3. Take home assignment
|
||||
|
||||
Frequency: Rare
|
||||
|
||||
There have been numerous debates on whether asking algorithm questions are a good way of assessing individual abilities as they aren't exactly the most relevant skills needed on a day-to-day basis at a job. Take home assignment is a format designed to address the shortcomings of the algorithm interview by getting candidates to work on larger projects which allow them to demonstrate software design skills.
|
||||
|
||||
However, this interview format takes up more time from both the candidates and the company and hence it is not as commonly seen in large companies where they have a high volume of candidates. This format is more common among startups and small companies. Examples
|
||||
|
||||
- Build a flights listing app
|
||||
- Build a kanban app
|
||||
- Build a snake game
|
||||
|
||||
### 4. Phone screen interviews
|
||||
|
||||
Frequency: Common
|
||||
|
||||
Phone interviews are the most common format and every candidate will face this at least once while interviewing. You will be asked to speak with an interviewer either over a phone call or VoIP (BlueJeans/Skype/Google Hangout). A question will be given to you and you will work on that question using an online collaborative editor (CoderPad/CodePen/Google Docs).
|
||||
|
||||
You are usually not allowed to execute the code even if the editor supports execution. So don't rely on that for verifying the correctness of your solution. Formats would differ slightly depending on the roles you are applying to. Many companies like to use [CoderPad](https://coderpad.io) for collaborative code editing. CoderPad supports running of the program, so it is possible that you will be asked to fix your code such that it can be run. For front end interviews, many companies like to use [CodePen](https://codepen.io), and it will be worth your time to familiarize yourself with the user interfaces of such web-based coding environments.
|
||||
|
||||
Check out [coding interview best practices](./coding-interview-best-practices.md) as well for do's and don'ts before your phone screen interviews.
|
||||
|
||||
### 5. Onsite
|
||||
|
||||
Frequency: Almost always
|
||||
|
||||
If you have made it to this stage, congratulations! This is usually the final stage before an offer decision. Candidates who made it to the onsite stage will be required to have an in-person interview at the office. If you are an overseas candidate, companies might even fly you in and pay for your accommodations!
|
||||
|
||||
The onsite stage usually consists of multiple rounds (coding, system design, behavioral) and is expected to last for a few hours. Since you are onsite, it is possible that you will be asked to do a whiteboard exercise with an interviewer, usually either solving an algorithm question or a system design question. It is also possible that you have to bring your own laptop and work on a project/solve a coding problem on the spot.
|
||||
|
||||
For onsite interviews at smaller (non-public) companies, most will allow (and prefer) that you use your own laptop. Hence it is important that you prepare your development environment in advance.
|
||||
|
||||
If the company provides lunch, you might also have a lunch session with an employee where you can find out more about the company culture.
|
||||
|
||||
## Pick a programming language
|
||||
|
||||
With your resume done, the next step of your software engineering interview journey is a simple one and won't take long - decide on a programming language. Unless you're interviewing for a specialist position like mobile or front end where there are domain-specific languages, you should be free to use any language you want for the algorithmic coding interviews.
|
||||
|
||||
Most of the time, you'd already have one in mind - pick the one you use the most and you're the most comfortable with. The most common programming languages used for coding interviews are Python, Java, C++, and JavaScript. I wouldn't recommend learning an entirely new language just for coding interviews as it takes a while (few weeks at least on average) to become proficient enough in a language to wield it comfortably in an interview setting, which is already stressful enough on its own. My personal programming language of choice is Python because of how terse it is and the functions/data structures the standard library provides.
|
||||
|
||||
Read more on programming languages for coding interviews: [Picking a programming language](./programming-languages-for-coding-interviews.md)
|
||||
|
||||
<!--
|
||||
References (omit when publishing)
|
||||
https://startupnextdoor.com/important-pick-one-language-for-the-coding-interview/
|
||||
-->
|
||||
|
||||
## Study and practice for coding interviews
|
||||
|
||||
The next and most important step is to practice solving algorithm questions in your chosen programming language. While Cracking the Coding Interview is a great resource, I prefer learning by actually solving problems.
|
||||
|
||||
There are many platforms that can be used for this - such as LeetCode, HackerRank and CodeForces. From my personal experience, LeetCode questions are most suitable for interview preparation whereas HackerRank and CodeForces are more for competitive programming.
|
||||
|
||||
However, LeetCode has thousands of questions and it can be daunting to know where to begin, or how to structure your practice. I have provided recommended preparation plans and also structured resources here:
|
||||
|
||||
### Coding interview study plan
|
||||
|
||||
The recommended time period to set aside for coding interview preparation is 3 months (11 hours a week i.e. 2-3 hours a day) for a more holistic preparation. I shared my [3 month study plan here](./coding-interview-study-plan.md), which provides a list of coding interview topics with resources and practice questions that you should work through in order of priority every week. I will also be adding content on recommended 1 month and 1 week study plans soon.
|
||||
|
||||
If you have less than 3 months to prepare, you can generate your own study plans using the [Grind 75 tool](https://www.techinterviewhandbook.org/grind75) (built by me) which generates recommended study plans for coding interviews based on the time you have left. The algorithm behind it includes a ranking of questions by priority and also a balance between breadth and depth of topics covered.
|
||||
|
||||
### Resources to use in your practice
|
||||
|
||||
In the market, there are plenty of resources vying for your attention, plenty of them just vying for your money but not providing any value. If I had to prioritize - these are the top coding interview preparation resources I would use in tandem:
|
||||
|
||||
1. [AlgoMonster](https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=)
|
||||
1. [Grokking the Coding Interview: Patterns for Coding Questions](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W)
|
||||
1. My (free) coding interview best practices guide
|
||||
1. My (free) coding interview techniques guide
|
||||
1. My (free) algorithms study guide
|
||||
|
||||
#### [AlgoMonster](https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=)
|
||||
|
||||
Apart from helping you master important coding interview data structures and algorithm questions through practice and easy to understand guides, AlgoMonster has the added perk of synthesizing [common interview question patterns](https://algo.monster/problems/stats) that you could apply to solve any other questions you have never encountered before. Made by Google engineers, this is definitely a quality platform to use as compared to the unstructured nature of LeetCode grinding. Data structures and algorithms questions are covered in all the common languages - Python, Java, C#, JavaScript, C++, Golang, and more. [**Join today for a 70% discount →**](https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=)
|
||||
|
||||
#### [Grokking the Coding Interview: Patterns for Coding Questions](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W)
|
||||
|
||||
This course on Educative expands upon the questions on the recommended practice questions but approaches the practicing from a questions pattern perspective, which is an approach I also agree with for learning and have personally used to get better at coding interviews. The course allows you to practice selected questions in Java, Python, C++, JavaScript and also provides sample solutions in those languages along with step-by-step visualizations. **Learn and understand patterns, not memorize answers!** [**Join today for a 10% discount →**](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W)
|
||||
|
||||
#### My (free) coding interview best practices guide
|
||||
|
||||
If you have read the [coding interview evaluation rubric](./coding-interview-rubrics.md) used at top tech companies, you may be overwhelmed by the number of items evaluated and how to demonstrate hire behaviors consistently.
|
||||
|
||||
This [coding interview best practices guide](./coding-interview-best-practices.md) synthesizes actionable recommendations of what to do before, during and after your coding interviews to demonstrate hire signals.
|
||||
|
||||
I recommend to internalize and use the guide as an accompaniment while you practice coding interview questions - to ensure that you cultivate good habits and muscle memory with regards to interviews right from the beginning.
|
||||
|
||||
#### My (free) coding interview techniques guide
|
||||
|
||||
Is there a structured method to increase your chances of finding a good solution to the coding interview question? How about optimizing your approach's time and space complexity? My coding interview techniques guide teaches you a few techniques for handling questions that you have never encountered before - such as problem visualizing, solving by hand, breaking the problem into subproblems, etc.
|
||||
|
||||
#### My (free) algorithms study cheatsheets
|
||||
|
||||
I'm not sure if these would qualify as an in-depth guide - they are more like 1-page "study cheatsheets" of the **best resources to study, best LeetCode questions to practice and the things to remember**. However, they ensure you cover all the most important grounds, especially when you have no time. Because these are also the notes that helped me clinch top tech offers - they definitely work.
|
||||
|
||||
For more tips on coding interview preparation, refer to my [full coding interview preparation guide](./coding-interview-prep.md) here.
|
||||
|
||||
### Try out mock coding interviews (with Google and Facebook engineers)
|
||||
|
||||
Coding right in front of your interviewer can be a nerve-wracking experience especially if you have never done it before - which is why getting hands-on experience is so important.
|
||||
|
||||
[interviewing.io](https://iio.sh/r/DMCa) is currently the best mock technical interview resource in the market currently. It allows you to book mock coding interviews with real Google and Facebook engineers, albeit anonymously. You could even book interviews for specific roles like Mobile, Front End, Engineering Management. Even better - if you want to have an easier transition into real world coding interview - you could view recorded interviews and see what phone interviews are like.
|
||||
|
||||
Moreover, if you were to do well on your mock interviews, you will be able to unlock the "jobs page" which allows you to book interviews directly with top companies like Uber, Lyft, Quora, Asana and more. I've used [interviewing.io](https://iio.sh/r/DMCa) both as an interviewer and an interviewee and found the experience to be excellent.
|
||||
|
||||
## Prepare for the system design interview
|
||||
|
||||
If you are a mid or senior-level candidate, you may expect system design questions as part of your technical interview. They aren't covered adequately by LeetCode and good resources are still harder to come by.
|
||||
|
||||
The objective of system design interviews is to evaluate a candidate's skill at designing real-world software systems involving multiple components.
|
||||
|
||||
### Utilize the best system design interview preparation resources
|
||||
|
||||
Some of the best system design interview preparation resources include:
|
||||
|
||||
1. ["Grokking the System Design Interview" on Educative](https://www.educative.io/courses/grokking-the-system-design-interview?aff=x23W) - This is probably the most famous system design interview course on the internet and what makes it different from most other courses out there is that it is purely text-based, which is great for people who prefer reading over watching videos (such as myself!). It contains a repository of the popular system design problems along with a glossary of system design basics. I've personally completed this course and have recommended many others to use this. Highly recommended!
|
||||
2. ["System Design Interview Course" by Exponent](https://www.tryexponent.com/courses/system-design-interview?ref=techinterviewhandbook) - This course covers system designs basics and has a huge database of popular system design questions with videos of mock interviews. Some of the questions have text answers and a database schema and APIs for reference (which I find helpful). While the subscription might be a little pricey for just the system design interviews content, they also offer quality technical content for [Data Structures](https://www.tryexponent.com/courses/swe-practice?ref=techinterviewhandbook), [Algorithms](https://www.tryexponent.com/courses/algorithms?ref=techinterviewhandbook) and [Behavioral Interviews](https://www.tryexponent.com/courses/behavioral?ref=techinterviewhandbook). The convenience of a one-stop platform which covers all aspects of technical interview preparation is very enticing.
|
||||
3. ["Grokking the Advanced System Design Interview" on Educative](https://www.educative.io/courses/grokking-adv-system-design-intvw?aff=x23W) - I haven't tried this but it's by the same people who created "Grokking the System Design Interview", so it should be good! In my opinion you probably wouldn't need this unless you're very senior or going for a specialist position.
|
||||
|
||||
[Check out other Systems Design preparation guides and resources here.](./system-design.md)
|
||||
|
||||
## Prepare for the behavioral interview
|
||||
|
||||
Every top tech company has at least one round of behavioral interviews for software engineers. Typically, behavioral interviews for software engineers include: Sharing about details of previous experiences on resume Providing examples of past situations and behavior that demonstrate certain behavioral attributes (e.g. conflict management, data driven) Sharing of ambitions and career plans
|
||||
|
||||
As much as these interviews seem "fluffy" or unstructured, there is actually a structured way to prepare for behavioral interviews:
|
||||
|
||||
### 1. Know the STAR format for answering them
|
||||
|
||||
The STAR format helps you to organize your answers to behavioral questions. This is most applicable to questions that require you to recount past experiences or behavior. Situation: Share details about the situation that gave rise to the task Task: Explain what you needed to achieve or the problems you had to solve, focusing on the scope, severity or specific benchmarks or outcomes you had to hit Action: Explain what you did to meet your objectives, describing options you had and how you made decisions Results: Describe the outcome of your actions and what you learnt
|
||||
|
||||
Read more: The STAR format for answering behavioral questions
|
||||
|
||||
### 2. Practice the most common behavioral questions for software engineers
|
||||
|
||||
Refer to the [top 30 most common behavioral questions](./behavioral-interview-questions.md) for Software Engineers
|
||||
|
||||
For more tips on behavioral interview preparation, refer to my [full behavioral interview preparation guide](./behavioral-interview.md) here.
|
||||
|
||||
<!-- which can be broken down into the following steps (these steps are covered in detail in my behavioral interview step-by-step guide):
|
||||
Understand how software engineers are evaluated during behavioral interviews
|
||||
Learn effective answer formats and tactics
|
||||
Practice the most commonly asked questions -->
|
||||
|
||||
## Negotiating the software engineer offer package
|
||||
|
||||
Finally, the last thing you absolutely need to prepare for before your interview is salary negotiation for software engineers. At any point during the interview process, conversation about salary may crop up. We also have in-depth guides about [negotiation strategies](./negotiation.md) and [software engineer compensation](./understanding-compensation.md).
|
||||
|
||||
And that is all from me - for more detail on each step of the software engineer interview preparation process, do dive into each topic within my handbook through the sidebar or by navigating to the next page!
|
@ -0,0 +1,265 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import React, {useEffect, useMemo} from 'react';
|
||||
import clsx from 'clsx';
|
||||
import {
|
||||
isActiveSidebarItem,
|
||||
usePrevious,
|
||||
Collapsible,
|
||||
useCollapsible,
|
||||
findFirstCategoryLink,
|
||||
ThemeClassNames,
|
||||
useThemeConfig,
|
||||
useDocSidebarItemsExpandedState,
|
||||
isSamePath,
|
||||
} from '@docusaurus/theme-common';
|
||||
import Link from '@docusaurus/Link';
|
||||
import isInternalUrl from '@docusaurus/isInternalUrl';
|
||||
import {translate} from '@docusaurus/Translate';
|
||||
import IconExternalLink from '@theme/IconExternalLink';
|
||||
import DocSidebarItems from '@theme/DocSidebarItems';
|
||||
import styles from './styles.module.css';
|
||||
import useIsBrowser from '@docusaurus/useIsBrowser';
|
||||
export default function DocSidebarItem({item, ...props}) {
|
||||
switch (item.type) {
|
||||
case 'category':
|
||||
return <DocSidebarItemCategory item={item} {...props} />;
|
||||
|
||||
case 'html':
|
||||
return <DocSidebarItemHtml item={item} {...props} />;
|
||||
|
||||
case 'link':
|
||||
default:
|
||||
return <DocSidebarItemLink item={item} {...props} />;
|
||||
}
|
||||
} // If we navigate to a category and it becomes active, it should automatically
|
||||
// expand itself
|
||||
|
||||
function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
|
||||
const wasActive = usePrevious(isActive);
|
||||
useEffect(() => {
|
||||
const justBecameActive = isActive && !wasActive;
|
||||
|
||||
if (justBecameActive && collapsed) {
|
||||
setCollapsed(false);
|
||||
}
|
||||
}, [isActive, wasActive, collapsed, setCollapsed]);
|
||||
}
|
||||
/**
|
||||
* When a collapsible category has no link, we still link it to its first child
|
||||
* during SSR as a temporary fallback. This allows to be able to navigate inside
|
||||
* the category even when JS fails to load, is delayed or simply disabled
|
||||
* React hydration becomes an optional progressive enhancement
|
||||
* see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
|
||||
* see https://github.com/facebook/docusaurus/issues/3030
|
||||
*/
|
||||
|
||||
function useCategoryHrefWithSSRFallback(item) {
|
||||
const isBrowser = useIsBrowser();
|
||||
return useMemo(() => {
|
||||
if (item.href) {
|
||||
return item.href;
|
||||
} // In these cases, it's not necessary to render a fallback
|
||||
// We skip the "findFirstCategoryLink" computation
|
||||
|
||||
if (isBrowser || !item.collapsible) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return findFirstCategoryLink(item);
|
||||
}, [item, isBrowser]);
|
||||
}
|
||||
|
||||
function DocSidebarItemCategory({
|
||||
item,
|
||||
onItemClick,
|
||||
activePath,
|
||||
level,
|
||||
index,
|
||||
...props
|
||||
}) {
|
||||
const {items, label, collapsible, className, href} = item;
|
||||
const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
|
||||
const isActive = isActiveSidebarItem(item, activePath);
|
||||
const isCurrentPage = isSamePath(href, activePath);
|
||||
const {collapsed, setCollapsed} = useCollapsible({
|
||||
// active categories are always initialized as expanded
|
||||
// the default (item.collapsed) is only used for non-active categories
|
||||
initialState: () => {
|
||||
if (!collapsible) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isActive ? false : item.collapsed;
|
||||
},
|
||||
});
|
||||
useAutoExpandActiveCategory({
|
||||
isActive,
|
||||
collapsed,
|
||||
setCollapsed,
|
||||
});
|
||||
const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
|
||||
|
||||
function updateCollapsed(toCollapsed = !collapsed) {
|
||||
setExpandedItem(toCollapsed ? null : index);
|
||||
setCollapsed(toCollapsed);
|
||||
}
|
||||
|
||||
const {autoCollapseSidebarCategories} = useThemeConfig();
|
||||
useEffect(() => {
|
||||
if (
|
||||
collapsible &&
|
||||
expandedItem &&
|
||||
expandedItem !== index &&
|
||||
autoCollapseSidebarCategories
|
||||
) {
|
||||
setCollapsed(true);
|
||||
}
|
||||
}, [
|
||||
collapsible,
|
||||
expandedItem,
|
||||
index,
|
||||
setCollapsed,
|
||||
autoCollapseSidebarCategories,
|
||||
]);
|
||||
return (
|
||||
<li
|
||||
className={clsx(
|
||||
ThemeClassNames.docs.docSidebarItemCategory,
|
||||
ThemeClassNames.docs.docSidebarItemCategoryLevel(level),
|
||||
'menu__list-item',
|
||||
{
|
||||
'menu__list-item--collapsed': collapsed,
|
||||
},
|
||||
className,
|
||||
)}>
|
||||
<div
|
||||
className={clsx('menu__list-item-collapsible', {
|
||||
'menu__list-item-collapsible--active': isCurrentPage,
|
||||
})}>
|
||||
<Link
|
||||
className={clsx('menu__link', {
|
||||
'menu__link--sublist': collapsible,
|
||||
'menu__link--sublist-caret': !href && collapsible,
|
||||
'menu__link--active': isActive,
|
||||
})}
|
||||
onClick={
|
||||
collapsible
|
||||
? (e) => {
|
||||
onItemClick?.(item);
|
||||
|
||||
if (href) {
|
||||
updateCollapsed(false);
|
||||
} else {
|
||||
e.preventDefault();
|
||||
updateCollapsed();
|
||||
}
|
||||
}
|
||||
: () => {
|
||||
onItemClick?.(item);
|
||||
}
|
||||
}
|
||||
aria-current={isCurrentPage ? 'page' : undefined}
|
||||
aria-expanded={collapsible ? !collapsed : undefined}
|
||||
href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
|
||||
{...props}>
|
||||
{label}
|
||||
</Link>
|
||||
{href && collapsible && (
|
||||
<button
|
||||
aria-label={translate(
|
||||
{
|
||||
id: 'theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel',
|
||||
message: "Toggle the collapsible sidebar category '{label}'",
|
||||
description:
|
||||
'The ARIA label to toggle the collapsible sidebar category',
|
||||
},
|
||||
{
|
||||
label,
|
||||
},
|
||||
)}
|
||||
type="button"
|
||||
className="clean-btn menu__caret"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
updateCollapsed();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
|
||||
<DocSidebarItems
|
||||
items={items}
|
||||
tabIndex={collapsed ? -1 : 0}
|
||||
onItemClick={onItemClick}
|
||||
activePath={activePath}
|
||||
level={level + 1}
|
||||
/>
|
||||
</Collapsible>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function DocSidebarItemHtml({item, level, index}) {
|
||||
const {value, defaultStyle, className} = item;
|
||||
return (
|
||||
<li
|
||||
className={clsx(
|
||||
ThemeClassNames.docs.docSidebarItemLink,
|
||||
ThemeClassNames.docs.docSidebarItemLinkLevel(level),
|
||||
defaultStyle && `${styles.menuHtmlItem} menu__list-item`,
|
||||
className,
|
||||
)}
|
||||
key={index} // eslint-disable-next-line react/no-danger
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: value,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function DocSidebarItemLink({
|
||||
item,
|
||||
onItemClick,
|
||||
activePath,
|
||||
level,
|
||||
index,
|
||||
...props
|
||||
}) {
|
||||
const {href, label, className} = item;
|
||||
const isActive = isActiveSidebarItem(item, activePath);
|
||||
const isInternalLink = isInternalUrl(href);
|
||||
return (
|
||||
<li
|
||||
className={clsx(
|
||||
ThemeClassNames.docs.docSidebarItemLink,
|
||||
ThemeClassNames.docs.docSidebarItemLinkLevel(level),
|
||||
'menu__list-item',
|
||||
className,
|
||||
)}
|
||||
key={label}>
|
||||
<Link
|
||||
className={clsx(
|
||||
'menu__link',
|
||||
!isInternalLink && styles.menuExternalLink,
|
||||
{
|
||||
'menu__link--active': isActive,
|
||||
},
|
||||
)}
|
||||
aria-current={isActive ? 'page' : undefined}
|
||||
to={href}
|
||||
{...(isInternalLink && {
|
||||
onClick: onItemClick ? () => onItemClick(item) : undefined,
|
||||
})}
|
||||
{...props}>
|
||||
{label}
|
||||
{!isInternalLink && <IconExternalLink />}
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
@media (min-width: 997px) {
|
||||
.menuHtmlItem {
|
||||
padding: var(--ifm-menu-link-padding-vertical)
|
||||
var(--ifm-menu-link-padding-horizontal);
|
||||
}
|
||||
}
|
||||
|
||||
.menuExternalLink {
|
||||
align-items: center;
|
||||
}
|
After Width: | Height: | Size: 311 KiB |
After Width: | Height: | Size: 274 KiB |
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 155 KiB |
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 149 KiB |