mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-04-13 13:19:49 +08:00
website: move into monorepo
This commit is contained in:
20
apps/website/.gitignore
vendored
Executable file
20
apps/website/.gitignore
vendored
Executable file
@@ -0,0 +1,20 @@
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# generated files
|
||||
.docusaurus
|
||||
.cache-loader
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
40
apps/website/README.md
Executable file
40
apps/website/README.md
Executable file
@@ -0,0 +1,40 @@
|
||||
# Website
|
||||
|
||||
This website is built using Docusaurus 2, a modern static website generator. It is part of a [Turborepo](https://turborepo.org/) monorepo setup.
|
||||
|
||||
### Installation
|
||||
|
||||
We use Yarn 1 as the package manager. At the root of the repository, run `yarn` to install the monorepo dependencies.
|
||||
|
||||
```sh
|
||||
$ yarn
|
||||
```
|
||||
|
||||
### Local Development
|
||||
|
||||
Also at the root of the repository, run:
|
||||
|
||||
```sh
|
||||
$ yarn dev:website
|
||||
```
|
||||
|
||||
This command starts a local development server and opens up a browser window. Most changes made to JavaScript and Markdown files will be reflected instantly without having to restart the server.
|
||||
|
||||
### Build
|
||||
|
||||
Navigate to the `apps/website` directory.
|
||||
|
||||
```sh
|
||||
cd apps/website
|
||||
$ yarn build
|
||||
```
|
||||
|
||||
This command generates static content into the `build` directory and can be served using any static contents hosting service.
|
||||
|
||||
### Deployment
|
||||
|
||||
```
|
||||
$ GIT_USER=<Your GitHub username> USE_SSH=1 yarn deploy
|
||||
```
|
||||
|
||||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
title: Are Front End Development Skills Enough for a Career?
|
||||
slug: are-front-end-development-skills-enough-for-a-career
|
||||
author: Yangshun Tay
|
||||
author_title: Front End Engineer at Facebook
|
||||
author_url: https://github.com/yangshun
|
||||
author_image_url: https://github.com/yangshun.png
|
||||
author_twitter: yangshunz
|
||||
tags: [front end, career]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
Recently, an undergrad freshmen I met at an event asked me a question regarding Front End development as a career.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
<head>
|
||||
<link rel="canonical" href="https://yangshuntay.com/blog/are-front-end-development-skills-enough-for-a-career/" />
|
||||
</head>
|
||||
|
||||
> I'm honestly quite into front end development — web technologies, UI/UX, web design and stuff. But with there being more and more accessible to new developers (create-react-app, parcel and such), I just can't help but wonder if these skills are sufficient to survive in the tech industry today. Not that it's a bad thing! Lowering the barrier to entry for programmers is always good. However, for those like myself who would like to pursue front end development as a career, I'm just wondering if having these skills are enough.
|
||||
|
||||
Interesting question. I've wondered the same question to myself before but convinced myself that I'm probably fine just dabbling in Front End development for now. 😌
|
||||
|
||||
## Front End is complex and getting increasingly so
|
||||
|
||||
Most people would have used websites like facebook.com, youtube.com and gmail.com. These applications have hundreds of engineers working on them (thousands if you include the back end) due to the demanding nature of the application - it has to load fast, it has to be secure, it has to look pretty. These days, front end development is no longer just about building websites rendering a static HTML. Many websites these days are in fact web applications and a lot of thought has to be put into the application architecture, and that requires good software engineering capabilities.
|
||||
|
||||
That's why you see many Front End tools these days like React, Redux, Relay, CSS modules, webpack, etc. These tools exist because of the ever-increasing requirements of building rich and performant user experiences on the web. [Being a good Front End developer](https://www.toptal.com/front-end/how-to-hire) is very hard, there are many aspects to know about - HTML, CSS, JavaScript, Browser APIs, Security, Performance, Animation, SEO, Networking, the list is non-exhaustive and growing. There are always new problems to solve and new things to learn. [JavaScript fatigue](https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4) was a term pretty common a few years back due to the explosion of tools in the Front End ecosystem. Things have gotten more stable but the JavaScript community is currently still one of the most fast-moving communities.
|
||||
|
||||
## Does the rise of mobile threaten the existence of web developers?
|
||||
|
||||
Many products now have a native mobile app version and that might make people think that the existence of Front End (web) developers could be threatened. I think that is only true to a small extent. Certain applications like Uber and Lyft make sense to be mobile-first, but there are also many complex professional applications where web (or any interface with a larger screens) will always prevail, such as office productivity and design software. Viewing things at a more macro scale, both mobile apps and web apps fall under the category of client-side applications. Many core skills important for being a good web developer are also important for mobile app development - they are transferable across platforms.
|
||||
|
||||
Tools like [React Native](https://reactnative.dev) and [Flutter](https://flutter.dev) have also been created to help engineers build products across platforms by only writing the code "once" (in quotes because that dream is still in development). This approach is not a silver bullet solution and has yet to prove itself adequately, but for prototyping small apps or even just certain parts of your mobile app, it works pretty well. In React Native, you write your application in JavaScript using React Native primitives, and the React Native runtime runs the code on the JavaScript engine in the platform to construct native app UI views and handle application logic. It's pretty similar to writing typical web front end code. Facebook's Ads Manager App and the Marketplace tab are built using React Native. There are numerous technologies that enable you to build native apps on mobile platforms by knowing web front end development.
|
||||
|
||||
Even though mobile usage is on the rise, there still exists many use cases where the desktop still excels at. Google Suite, Microsoft Office, Design tools are still more efficiently operated on desktops. In fact, many desktop applications these days are built on HTML5 technologies instead of native desktop code using tools like Electron to package web application code into an executable shipped to users. You might already be using some of them without knowing - Slack, Discord, WhatsApp Desktop, VS Code, Atom Editor, just to name a few. I think developers who are only familiar with native desktop platform engineering skills have more reasons to worry than Front End developers.
|
||||
|
||||
The web is incredibly cross-platform!
|
||||
|
||||
## Jack of all trades, master of one
|
||||
|
||||
However, I think that being a Front End development in many regards, is considered a specialized position. That's why it's important to be "T-shaped". I first got introduced to this term through my ex-manager at Grab, Tim Goh. He advised me to have a specialization (front end), yet still know a bit about everything. In other words, you are strong in your core fundamentals, but you also specialize in a particular area.
|
||||
|
||||
This is good advice and it's not new advice. In most university courses, students are expected to study the fundamental courses before choosing their area of specialization. In the context of a School of Computing in National University of Singapore, students start their in school by taking basic classes in Algorithms, Data Structures, Software Engineering, Operating Systems, Computer Networks, before choosing their specialization in deeper areas like Compilers, Computer Graphics, AI and Machine Learning, Media, Networking and more.
|
||||
|
||||
Having a strong foundation enables someone to make switching domains a possibility. There will definitely be a ramp-up process, but it can be made smoother with solid foundations, and with the skill of learning how to learn fast. In the extreme case where the web becomes irrelevant, and no companies want to hire front end developers anymore, front end developers with strong fundamentals can always slightly switch tracks by doing mobile or back end engineering, or even the hottest UI platform (AR/VR?) out there.
|
||||
|
||||
Having good tools to use (like Create React App, Parcel) doesn't eradicate the need for Front End developers to possess good software engineering skills. What will happen if you are the person tasked to build the tools? Great Front End developers (or Software Engineers really) go beneath the abstractions layer, understand how their tools work, and what problems the tool set out to solve. They also constantly seek to challenge and improve the status quo by building better technologies to cater to the ever-increasing demands.
|
||||
|
||||
At Facebook, the Front End Engineers are Software Engineers first, domain experts second. Many of the Front End engineers I know at Facebook have a deep understanding of the technical stack and don't just work on stuff related to the browser. At Facebook scale, front end work also involves building a lot of infrastructure to make our front end code base scale well with the growing technical and people needs. That means writing [codemods](https://github.com/facebook/jscodeshift) to do large-scale refactoring, inventing new [UI](https://reactjs.org) [paradigms](http://facebook.github.io/flux/), performant [testing frameworks](https://jestjs.io), creating [type-checkers](https://flow.org) for untyped languages, changing the ways we [fetch data](https://graphql.org) from our servers and [managing it on clients](https://relay.dev). These tools wouldn't exist if the Front End engineers at Facebook didn't possess strong software engineering skills.
|
||||
|
||||
## Pick up new, relevant skills
|
||||
|
||||
It can be hard to pick up new skills at work in an unrelated domain if there are no opportunities to do so. Thankfully (or not), due to the explosion of tools in the Front End ecosystem, I've found an area which I have gained a new-found interest in - Programming Languages Theory (Static Analysis, Compilers, and Intepreters). Static analysis is incredibly important in tools that I use on a daily basis - it's being used by the module bundlers for bundling JavaScript files together, generating CSS from more user-friendly CSS syntaxes, compiling modern JavaScript into older versions of JavaScript that more common browsers can run, and even this blog post written in Markdown uses static analysis to be converted into HTML.
|
||||
|
||||
I've been toying with writing my own interpreter after learning this awesome book called [Crafting Interpreters](http://www.craftinginterpreters.com) and will be further exploring this domain in my spare time, possibly building Front End-related tooling in future that leverages static analysis and compilation.
|
||||
|
||||
Adding new skills to my arsenal in a related but different domain helps me to stay relevant in the event that the industry no longer needs Front End developers 😱
|
||||
|
||||
---
|
||||
|
||||
In summary, although Front End development is considered quite specialized, there's enough demand and complexity for it to stay relevant in the years to come. What would threaten the web would be an entire shift of the way users interact with apps, perhaps to a non-visual paradigm like a brain-controlled interface. However, paradigm shifts don't happen overnight and there will be sufficient time to react (pun intended) in the case that ever happens. Being strong in your Software Engineering fundamentals and knowing how to learn new skills fast will help you in switching domains (and also careers).
|
||||
|
||||
_Opinions are my own and do not represent the views of my employer._
|
||||
133
apps/website/blog/2020-05-28-summing-root-to-leaf-numbers.md
Normal file
133
apps/website/blog/2020-05-28-summing-root-to-leaf-numbers.md
Normal file
@@ -0,0 +1,133 @@
|
||||
---
|
||||
title: Summing Root To Leaf Numbers
|
||||
slug: summing-root-to-leaf-numbers
|
||||
author: Raivat Shah
|
||||
author_title: Student at NUS Computing
|
||||
author_url: https://github.com/raivatshah
|
||||
author_image_url: https://github.com/raivatshah.png
|
||||
tags: [leetcode, trees, problem-solving]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
Sum Root to Leaf Numbers is an [interesting problem from LeetCode](https://leetcode.com/problems/sum-root-to-leaf-numbers/). The problem is of medium difficulty and is about binary trees. This post is an explains the solution to the problem.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
I assume that you're familiar with Python and the concept of binary trees. If you're not, you can read [this article](https://www.tutorialspoint.com/python_data_structure/python_binary_tree.htm) to get started.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||

|
||||
|
||||
## The Problem
|
||||
|
||||
Given a binary tree whose nodes contain values `0-9`, we have to find the sum of all numbers formed by root-to-leaf paths. A leaf is a node that doesn't have any child nodes. **In a binary tree, a root-to-leaf path is always unique**. Here below is the expected behavior of the solution required:
|
||||
|
||||

|
||||
|
||||
In the tree on the left, the output is `25`. `25` is the sum of `12` and `13`, which are the two numbers formed when starting from `1` and visiting every leaf. In the tree on the right, the output is `1026` as it is the sum of the three numbers `495`, `491` and `40`.
|
||||
|
||||
## The Observations and Insights
|
||||
|
||||
1. To construct a number, we traverse the tree from the root to the leaf, appending digits where the most significant digit is at the root, and the least significant digit is at the leaf. We visit some leaves before other nodes that are closer to the root. This suggests that a depth-first search will be useful.
|
||||
|
||||
2. The _construction_ of numbers is incremental and similar of sorts: the only difference between `495` and `491` (from the tree on the right) is the last digit. If we remove the `5` and insert a `1` in its place, we have the next required number. A number essentially comprises of the leaf's digit appended to all the digits in ancestor nodes. Thus, numbers within the same subtree have common digits.
|
||||
|
||||
3. Finally, notice that this problem involves a tree, so a recursive solution is helpful.
|
||||
|
||||
## The Solution
|
||||
|
||||
We can do a `pre-order` traversal of the tree where we incrementally construct a number and exploit the fact that numbers formed by nodes in the same sub-tree have common digits. When we're done forming numbers in a sub-tree, we can backtrack and go to another sub-tree.
|
||||
|
||||
Let's create a `Solution` class to encompass our solution.
|
||||
|
||||
```py
|
||||
class Solution:
|
||||
def sum_numbers(self, root: TreeNode) -> int:
|
||||
```
|
||||
|
||||
The method signature given to us in the problem has one argument: root, which is of the type `TreeNode` . A `TreeNode` class is as follows (from LeetCode):
|
||||
|
||||
```py
|
||||
class TreeNode:
|
||||
def __init__(self, val=0, left=None, right=None):
|
||||
self.val = val
|
||||
self.left = left
|
||||
self.right = right
|
||||
```
|
||||
|
||||
From observation #2, notice that appending a node's digit to its ancestors can be achieved by _moving_ all the digits of the number formed by ancestors to the right by 1 place and adding the current node's digit. The digits can be _moved_ by multiplying the number formed by ancestors by 10 (since we're in base-10). For example:
|
||||
|
||||
`495 = 49 x 10 + 5`
|
||||
|
||||
Thus, we can keep track of the _current_ digits in an integer. This is important because we won't incur extra storage space for higher input sizes. We can pass around this value in the function parameter itself. Since the method signature given can only have one parameter, let's create a `sum_root_to_leaf_helper` method.
|
||||
|
||||
We can think of the `sum_root_to_leaf_helper` method recursively and process each node differently based on whether or not it is a leaf.
|
||||
|
||||
- If the node is a leaf, we want to add its digit to our current digits by moving all the other digits to the right. We also want to return this value (since we'll backtrack from here).
|
||||
|
||||
- If it is not a leaf, we want to add the digit to our current digits by moving all the other digits to the right. We also want to continue constructing the number by traversing down this node's left and right subtrees.
|
||||
|
||||
If the current node is a `None`, we can simply return 0 because it doesn't count.
|
||||
|
||||
Thus, our `sum_root_to_leaf_helper` method will be as follows:
|
||||
|
||||
```py
|
||||
def sum_root_to_leaf_helper(node, partial_sum=0):
|
||||
if not node:
|
||||
return 0
|
||||
partial_sum = partial_sum * 10 + node.val
|
||||
# Leaf
|
||||
if not node.left and not node.right:
|
||||
return partial_sum
|
||||
# Non Leaf
|
||||
return (sum_root_to_leaf_helper(node.left, partial_sum) + \
|
||||
sum_root_to_leaf_helper(node.right, partial_sum))
|
||||
```
|
||||
|
||||
We use a default value for the partial sum to be 0.
|
||||
|
||||
In our main method, we want to include the `sum_root_to_leaf_helper` method as a nested method and simply pass on the node parameter. Finally, this is how our solution looks:
|
||||
|
||||
```py
|
||||
class Solution:
|
||||
def sumNumbers(self, root: TreeNode) -> int:
|
||||
def sum_root_to_leaf_helper(node, partial_sum=0):
|
||||
if not node:
|
||||
return 0
|
||||
partial_sum = partial_sum * 10 + node.val
|
||||
# Leaf
|
||||
if not node.left and not node.right:
|
||||
return partial_sum
|
||||
# Non Leaf
|
||||
return (sum_root_to_leaf_helper(node.left, partial_sum) + \
|
||||
sum_root_to_leaf_helper(node.right, partial_sum))
|
||||
|
||||
return sum_root_to_leaf_helper(root)
|
||||
```
|
||||
|
||||
## The Algorithmic Complexity
|
||||
|
||||
When we come up with a solution, it is important to analyze its algorithmic complexity not only to estimate its performance but also to identify areas for improvement and reflect on our problem-solving skills. We should always ask the question: _can we do better than X?_ Where X is the current complexity of our solution.
|
||||
|
||||
Time:
|
||||
|
||||
Our solution is a modification of the depth-first-search pre-order traversal where we visit all nodes exactly once and perform a trivial computation (moving digits by integer multiplication). Thus, our runtime is simply `O(N)` where `N` represents the number of nodes in the given tree. A solution better than `O(N)` doesn't seem possible because to construct a number from digits, we need to know all the digits (and thus visit all nodes).
|
||||
|
||||
Space:
|
||||
|
||||
In terms of storage, we incur a high cost in the recursion call stack that builds up as our `sum_root_to_leaf_helper` calls itself. These calls _build-up_ as one waits for another to finish.
|
||||
|
||||
The maximum call stack is dependent upon the height of the binary tree (since we start backtracking after we visit a leaf), giving a complexity of `O(H)` where `H` is the height of the binary tree. In the worst case, the binary tree is skewed in either direction and thus `H = N`. Therefore, the worst-case space complexity is `O(N)`.
|
||||
|
||||
You can read [this article](https://www.freecodecamp.org/news/how-recursion-works-explained-with-flowcharts-and-a-video-de61f40cb7f9/) to know more about recursion call stacks.
|
||||
|
||||
It is possible to do better than `O(N)` by using a Morris Preorder Traversal. The basic idea is to link a node and its predecessor temporarily. You can read more about it [here](https://www.sciencedirect.com/science/article/abs/pii/0020019079900681).
|
||||
|
||||
## The Conclusion
|
||||
|
||||
I hope this post helped! Please do let me know if you have any feedback, comments or suggestions by responding to this post.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Advay, Kevin, Louie for reviewing this post and Yangshun for the idea of adding it as a blog post.
|
||||
@@ -0,0 +1,83 @@
|
||||
---
|
||||
title: Importance of Communicating Effectively as Engineers
|
||||
slug: importance-of-communicating-effectively-as-engineers
|
||||
author: Yangshun Tay
|
||||
author_title: Engineering Lead at Facebook
|
||||
author_url: https://github.com/yangshun
|
||||
author_image_url: https://github.com/yangshun.png
|
||||
tags: [career, communication]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
import BadCommunicationURL from '@site/static/img/bad-communication.jpg';
|
||||
|
||||
**_tl;dr: communicating effectively broadly and frequently helps you grow as an engineer and we have many tools built to do that!_**
|
||||
|
||||
At Facebook where I work at, strong communication is crucial for a successful career. As engineers, sometimes we get too focused on execution and it's easy to forget about communicating our work broadly. Perhaps some of us are new to a large engineering organization and previously did not have the tools to foster communication nor was it emphasized by the company.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
<head>
|
||||
<link rel="canonical" href="https://yangshuntay.com/blog/importance-of-communicating-effectively-as-engineers/" />
|
||||
</head>
|
||||
|
||||
I love to code. Personally, I would love to shut off all communication channels and focus entirely on coding if I could. However, doing that will probably have disastrous effects. Communication is super important and I learnt that the hard way when I first started at Facebook. In my first year at Facebook, I made a few painful mistakes related to communication. I changed the project plans and timeline without informing my tech lead, resulting in my teammate having to cover me at the last minute and do the work I reprioritized without telling anyone. In another instance, I didn't communicate that I was going to do some work that my teammate had planned to do, resulting in wasted efforts. From then on, I made a mental note to myself to communicate broadly and early wherever possible and seek alignment. I'd err on the side of over-communicating rather than under-communicating (though sometimes I still forget).
|
||||
|
||||
<div class="text--center">
|
||||
|
||||
<figure>
|
||||
<img alt="You cannot have bad communication if you never communicate" src={BadCommunicationURL} />
|
||||
<figcaption>Just like you can't cause any bugs if you don't write any code.</figcaption>
|
||||
</figure>
|
||||
|
||||
</div>
|
||||
|
||||
## Why is communication important?
|
||||
|
||||
Most engineers in organizations don't work alone. When you work with people, you have to communicate with them — to set expectations, seek feedback, align on decisions, what not. However, given that remote working is the norm for most of us now, we rarely see each other face to face (I haven't met anyone on the team in person since remote work started). In product teams like the ones we have in Commerce Engineering Singapore, we work with a myriad of XFN partners across the globe in different timezones. These factors make it challenging to be in regular touch and makes it even more important to communicate widely. We have to explicitly communicate through stand ups, weekly syncs, retros, Work Chat messages, Workplace posts, etc.
|
||||
|
||||
Communicating well frequently and broadly helps you to:
|
||||
|
||||
### Broaden your impact
|
||||
|
||||
If you have built something that's useful for yourself/your team, chances are, they will be useful for others as well, so tell more people about it! My first project at Facebook was to build Sentinel, an internal code attribution tool for the humongous Ads code base with nearing a decade's history. The tool solved the problem of people/bots changing a set of files which they were unfamiliar with and not knowing who the best reviewers for those changes were. Nothing about the tool was specific to Ads. After building an MVP (Minimum Viable Product) version of the tool, we reached out to various tools within Facebook which use their own bespoke code attribution approach and we eventually helped to replace them with Sentinel attribution. We also integrated it with popular tools like our IDE (a FB-specific VS Code), our internal component library, and our internal in-browser code explorer. At the end of that half (2018 H1), Sentinel was used by 2% of all diffs at Facebook, which was a pretty significant number. As of writing, over half a million diffs at Facebook have used Sentinel and I would say a huge part of its success was due to the network effects generated by word-of-mouth advertising by our early adopters, our push to integrate it into popular tools, and links within these tools that Sentinel was powering the attribution.
|
||||
|
||||
Takeaway — Make a noise! **A good product that many people use has more impact than an excellent product that few people use.** Sentinel wasn't perfect at the time of launch but it worked well enough. One of the easiest ways to get people to use your product is to tell people about it! It can't get any easier. Getting some people to use your product early also gives you the chance to iterate on feedback and make it better before you launch it to a wider audience.
|
||||
|
||||
### Improve your career performance and progression
|
||||
|
||||
Communication has a huge impact on one's performance. If you aren't able to effectively update your manager on what you are doing, it is hard for them to help you stay on track to ensure you meet expectations for the half. At Facebook, Communication is explicitly stated as an evaluation axis of our performance review, but realistically, every axis involves communication. We saw how effective communication helps expand one's project impact in the Sentinel example above. Better engineering practices should be communicated to folks who work on the same code base so as to efficiently deliver products of excellent implementation quality. Strong communication also leads to successful conflict resolution, mentorship and recruiting.
|
||||
|
||||
Here's a scenario on how communication impacts calibrations - Alice's manager put her up for promotion to Staff Engineer after successfully delivering on an impactful project. However, due to lack of communication and visibility about her project, it's the first time other managers in the room heard about this project and many raised questions regarding it due to their unfamiliarity with it. This made the calibration process much harder than it should have been had Alice communicated about her project broadly earlier on.
|
||||
|
||||
### Influence
|
||||
|
||||
Influence is a core skill you need to develop as you grow your career, and communication is at the core of it. Senior folks are leaders and influential and are effective communicators. This is true regardless of IC (individual contributor) track or management track. Senior Engineers are expected to be able to influence the engineering culture in the broader team and possess strong communication skills to be able to explain technical information effectively. Recently I attended a meeting with a very senior Software Engineer and was blown away by how he managed to explain the concept of cookies in such simple terms to the non-technical folks in the meeting and how effective communication helps you to get things done. For those who are interested in embarking on the manager track in future, please also know that most of an engineering manager's job involves communication.
|
||||
|
||||
### Foster alignment and save effort down the road
|
||||
|
||||
At large companies of similar scale as Facebook, it's not uncommon for two teams at Facebook to face the same problem. I'll use Sentinel as an example again. By communicating about the project broadly and early, we reduced the possibility of teams working in silos to solve the same problem and leading to duplicated efforts. By knowing which teams faced similar problems and understanding their unique circumstances, we were able to collaborate on the problem and accounted for the different needs of the various teams, achieving a 1 + 1 = 3 effect.
|
||||
|
||||
### Facilitate project planning and ensure timelines are met
|
||||
|
||||
Imagine this extreme (but still plausible) scenario - Bob and his team have spent a few months working on a huge project which was slated to launch next week. However, the project is only half-completed due to unforeseen technical difficulties and lack of manpower. If Bob had communicated about the difficulties and progress earlier, his manager could have allocated more manpower earlier to help out, and the team would probably be in a better position to meet their deadlines. This scenario is unrealistic at Facebook in the sense that such issues would probably be caught earlier because of weekly syncs and progress update posts. However, it is still possible for smaller projects where there aren't any/many syncs.
|
||||
|
||||
## Ways to communicate effectively
|
||||
|
||||
Hopefully by now you agree with me that communicating effectively broadly and frequently is important! Here are some tips on how to go about doing that:
|
||||
|
||||
### Leverage Communication Channels
|
||||
|
||||
Each company has its own communication channel - Slack, Discord, Google Suite, etc. At Facebook, we use [Workplace](https://workplace.com/), which is similar to the core Facebook app, but for your company and every co-worker is a friend. Workplace is literally a communication tool and it is also the easiest way to get the word out about something. Draft a Workplace post/note and post it in the relevant groups. Attach screenshots/videos to better illustrate the point and catch peoples' attention. Add tl;drs at the top of your posts. Structure your posts according to sections for better organization. If you are unsure about what content should go in your post, seek a review from your manager/tech lead, most likely they'll be happy to help.
|
||||
|
||||
### Write Wikis
|
||||
|
||||
Write wikis for posterity and so that your work appears in intern search results. Add links to your new wiki in existing relevant wikis. Doing all these improves the discoverability of your work.
|
||||
|
||||
### Shamelessly reach out to folks
|
||||
|
||||
If you know of someone/another team that would benefit from your work or the information, reach out to them and let them know! Even if they don't have an immediate need for your work, they might in future, or can inform others about it. The relationships you build along the way might surprise you.
|
||||
|
||||
---
|
||||
|
||||
Thanks to my manager [Nishita Agarwal](https://www.linkedin.com/in/nishita-agarwal-51872514/) and my teammate, [Yao Yang Leow](https://www.linkedin.com/in/leow-yao-yang/) for proofreading and giving feedback on earlier drafts.
|
||||
@@ -0,0 +1,405 @@
|
||||
---
|
||||
title: Facebook Career Q&A
|
||||
slug: facebook-career-questions-and-answers
|
||||
author: Yangshun Tay
|
||||
author_title: Engineering Lead at Facebook
|
||||
author_url: https://github.com/yangshun
|
||||
author_image_url: https://github.com/yangshun.png
|
||||
tags: [career, facebook, meta]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
A number of students from the Project Intern group have been asking me questions related to Facebook internships, working at Facebook, and my personal journey. I decided to write down my answers in the form of a blog post so they can be shared more broadly and I can point people to this blog post in future whenever I get asked similar questions.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
<head>
|
||||
<link rel="canonical" href="https://yangshuntay.com/blog/facebook-career-questions-and-answers/" />
|
||||
</head>
|
||||
|
||||
**_I am not a recruiter and I might have answered some of the recruiting or internship-related questions wrongly, so take them with a grain of salt. Opinions expressed are my own and do not represent the views of my employer._**
|
||||
|
||||
## Glossary
|
||||
|
||||
- APAC - Asia Pacific Region
|
||||
- CVWO - Computing for Voluntary Welfare Organizations
|
||||
- DSA - Data Structures and Algorithms
|
||||
- EE - Enterprise Engineer/ing
|
||||
- FRL - Facebook Reality Labs
|
||||
- FTE - Full-time Employee
|
||||
- IANACP - I am not a career portal
|
||||
- IANAR - I am not a recruiter
|
||||
- IANAL - I am not a lawyer
|
||||
- IINW - If I'm not wrong
|
||||
- RA - Residential Assistant
|
||||
- SWE - Software Engineer/ing
|
||||
- TPM - Technical Program Manager
|
||||
|
||||
## Caveats
|
||||
|
||||
- These replies are tailored towards the Facebook interview process for interns and fresh grads. They may or may not apply to other companies, especially smaller ones.
|
||||
- Most of these answers apply across the board for every engineer role but there are exceptions for certain specialized engineering roles like Security Engineering or Front End Engineering.
|
||||
|
||||
## Application/Referral
|
||||
|
||||
### What's the application process like (for internships)?
|
||||
|
||||
Apply on https://www.facebook.com/careers. Recruiters will reach out to you if there's interest and chat with you over the phone. If it goes well, there will be two rounds of coding interviews.
|
||||
|
||||
### What are some qualities/experiences that Facebook looks for in a resume?
|
||||
|
||||
IANAR and I don't filter any resumes, so I don't exactly know. But from experience, write stuff that makes you stand out from the rest. Have good grades? Add it in. Scholarships/awards, write them down. Have extensive internship experience? Include them in an organized format. Built cool hacks/side projects? Add the GitHub links and demos. Won hackathons/competitions? Put them in. One thing is for sure - few companies would want to hire candidates who only have academic credentials and no industry experience.
|
||||
|
||||
### Does GPA affect a lot on the resume screening?
|
||||
|
||||
GPA/CAP/grades is just one of the signals that can be extracted from the resume. As mentioned above, there are many other qualities and achievements a candidate can possess. Personally if I had my own company, I would rather hire a candidate with a high second upper and fantastic open source portfolio with multiple internship experiences at big companies over a student with CAP 5.00 but has nothing else to show for. Not that one candidate is stronger than the other, but the former would probably be a safer choice.
|
||||
|
||||
### In general, how's the barrier of entry for big tech companies like FB in terms of grades, would a second lower (3.5-3.9) even get pass the resume screening stage?
|
||||
|
||||
Grades matter less the longer someone has left school. For students, because there's a lack of working experience, grades might play a larger part in the resume screening, but it's by no means the only thing that matters.
|
||||
|
||||
### Is the resume screening done by AI / human recruiter? What is being looked out for on the resume? As someone who isn't strong academically, will I be able to compete purely based on experience on my resume?
|
||||
|
||||
IANAR. Usually people suck at their studies because instead of studying they spent their time elsewhere. If it was spent on related stuff like hacking on side projects and internships, that probably makes up for the subpar academic grades. But if you suck at studies and spent your time clubbing instead, then I'm sorry you probably won't get past the screening. Note that CS is such a hot course now that only the best students can get in these days. A fair amount of students have both good grades AND non-academic achievements. Competition is tough!
|
||||
|
||||
### Are there any languages/frameworks that are helpful to know before applying?
|
||||
|
||||
For Software Engineering (SWE) positions, Facebook doesn't require you to have experience in specific languages/frameworks before joining. Likewise, there aren't any of such restrictions for SWE interviews. You can do your interviews in your programming language of choice. One exception to this is if you're applying for a Front End Engineer or Mobile Engineer position, then you will be asked domain-specific questions and by extension, required to use JavaScript/Java/Kotlin/Objective-C/Swift to answer the questions.
|
||||
|
||||
### Are intern applications (and hence, the spots) based on first-come-first-served?
|
||||
|
||||
IANAR. But as with all jobs, there are definitely limited spots and once they're filled up there isn't a need to hire anymore. Applying in 2022 for the internship which application opens in September, is almost definitely too late. You can apply later (October) if you want more time to prepare, but there might be fewer slots left. Moral of the story - prepare early.
|
||||
|
||||
### How's the referral process about/like?
|
||||
|
||||
Facebook will send you a form (initiated by me) where you can fill up your name, email, upload your resume, and select the roles you would like to apply. From there on, from an applicant perspective it's not different from them applying themselves on the Facebook Careers Portal.
|
||||
|
||||
### May I know until when your referral is valid? I was hoping to start my application a bit later so was hoping to reach out to you then for a referral. Is there any last date to "claim" this in any way?
|
||||
|
||||
As long as I remain employed at Facebook, I'm happy to refer you if I feel that you stand a good chance passing the interviews. As mentioned earlier, if you apply when unprepared, you risk wasting the chance. Take too long and apply too late, then you risk the slots being all filled up. I don't know the last date to be referred but I recommend not later than end of September.
|
||||
|
||||
### Any tips for a good resume to apply for FB?
|
||||
|
||||
Answered above. I don't think most students need to worry about the resume screening stage. Worry about the interviews. Use a neat and standard template and you should be fine.
|
||||
|
||||
If you're applying for US positions, it'd be helpful to do the following:
|
||||
|
||||
- Mention expected year of graduation (month as well if you know)
|
||||
- If you're applying to US roles, mention US work eligibility. This is straightforward for Singaporeans (mention eligibility for H-1B1 visa)
|
||||
- Use GPA instead of CAP
|
||||
|
||||
### If I build my projects must some of them be pushed to production before applying?
|
||||
|
||||
Best if you can, but I'm not sure if recruiters actually click on your project links. Maybe just don't include the link if it's not really usable?
|
||||
|
||||
### Do you have any tips in applying for a fresh grad SWE role in facebook?
|
||||
|
||||
Make sure you know your algorithms at the back of your hand. Fresh grad SWE role interviews also have a behavioral round, so be prepared to talk about your past experiences. There's a section in this handbook which covers those.
|
||||
|
||||
### Apart from preparing for DSA questions, are there other areas you would recommend preparing for (either for the interviews / a better chance to get shortlisted for them)?
|
||||
|
||||
If you're going for a SWE intern/grad position, DSA is the most important. The bulk of the assessment is on DSA. Grind your LeetCode.
|
||||
|
||||
## Would love to find out what the interviewers at Facebook usually look out for in candidates!
|
||||
|
||||
DSA. DSA. DSA. Communication skills - You must be able to also communicate your thought process well throughout the interview.
|
||||
|
||||
### Am I able to apply for both local and overseas (in the USA) roles for FB and be considered for both? Or would I only be considered for SG's openings since FB has an office here and I'm already located in SG?
|
||||
|
||||
IANAR. Typically you will only be interviewed for one location. Candidates based in Singapore are free to apply to non-Singapore positions and intern there.
|
||||
|
||||
### What is the application process like for the Software Engineer role? Is it any different from the Enterprise and Front End Engineer role?
|
||||
|
||||
For SWE, I've answered above. I'm not sure about Enterprise Engineers, I suspect it wouldn't be too different. For Front End Engineers, the questions will be domain-specific, hence will require candidates to be familiar with HTML/CSS/JS/Vanilla JS DOM manipulation methods, and less emphasis on Data Structures and Algorithms. I would expect most students to not have enough domain expertise to pass a Front End Interview, so don't anyhow apply for it. Simple litmus test - can you build a TODO list app in pure vanilla JavaScript, without using React/jQuery?
|
||||
|
||||
Note that Facebook Singapore currently does not hire Front End Engineers and interns. If you're interested in a Front End Engineer internship/FTE position, you'd have to look overseas.
|
||||
|
||||
### Is there anything I can do/prepare to improve my chances of getting through the recruiter screen?
|
||||
|
||||
1. Get a referral
|
||||
1. Have a solid neat resume that showcases your abilities
|
||||
|
||||
### How much does a referral help in landing a interview?
|
||||
|
||||
Referrals tend to have a higher visibility than someone who applies on the Careers Portal directly, but that's about it.
|
||||
|
||||
### Are there any related full time openings at FB, and if so how can I help you decide if I'm a good candidate to refer?
|
||||
|
||||
I look through your transcript and resume and look for stuff that suggests you'd make a good employee. What things I look out for - excellent grades in the relevant modules, notable internships, interesting side projects, ICPC/IOI awards. Bonus: Open Source experience. I'm a huge fan of Open Source and if you have built something really cool that's Open Source, I'd refer you even if your grades are terrible.
|
||||
|
||||
### Do I stand a good chance if I'm from a Info Systems background but gotten good grades for programming modules? Currently taking some CS modules now too.
|
||||
|
||||
There are many IS folks who are good engineers. As long as you can demonstrate that you have mastery of programming and DSA, it shouldn't be an issue.
|
||||
|
||||
### Would you know whether Facebook's hiring process has a preference for single-page resumes?
|
||||
|
||||
As an interviewer for FB senior-ish candidates, I have seen some horrendously long resumes. So I would think single-page is not a hard rule, more of a recommendation. If you are exceeding a single page, then you are likely including too many things. [My own resume](https://docs.google.com/document/d/13c8KsKSsP5biJT8N70aLULyq-I5ywuWrxRxr2faQTK4/) is a 2-column one with small-ish font which I used in my last job hunt in 2017. It has got me replies from recruiters. This was before I started working at Facebook, so the Facebook branding isn't the main reason.
|
||||
|
||||
### I'm an international student at SMU, does Facebook sponsor employment pass?
|
||||
|
||||
IANAL. But we have had international students interning at Facebook before and are currently working at Facebook. Please check with the recruiter.
|
||||
|
||||
### I'm from SUTD and my schedule is pretty weird! I'm graduating next year so should I apply for internship or a job?
|
||||
|
||||
If you have any spare summers left, you can and should go for an internship. IMO passing an internship interview is easier than a full-time interview, and likely leads to a better conversion package also if you have performed well during the internship.
|
||||
|
||||
### Am I eligible to work overseas in US/London/Canada?
|
||||
|
||||
IANAR. If you're Singaporean, you'd have no problems working anywhere. If you're a foreign student, you could check with your seniors or just ask the recruiter when you get the chance.
|
||||
|
||||
### I want to intern in SG and work in US. Is that possible?
|
||||
|
||||
For interns, your return offer will be for the location you interned in. So you should also factor in where you want to work full-time and strive to intern at the same location.
|
||||
|
||||
### How long do I have to wait if I get rejected?
|
||||
|
||||
There's a 6-month to 1-year cooldown period for each role - E.g. if you've interviewed for SWE in the US and failed, you'd have to wait some amount of time before interviewing for the SWE position again in SG (or any location). This cooldown is per role, so you're free to apply again immediately and interview for another role, e.g Front End Engineer, assuming your resume gets picked up.
|
||||
|
||||
As of writing, internships in FB SG are run annually so if you fail this year you'd have to wait for the next.
|
||||
|
||||
## Interviews
|
||||
|
||||
### What's the interview process like?
|
||||
|
||||
For all roles, there should be an initial contact (e.g. phone call) with recruiters. For interns, it would be 2 rounds of online coding interviews where the focus is on DSA. For fresh graduates, it would be 2 rounds of online coding interviews and 1 behavioral round.
|
||||
|
||||
### Based on your past experience, if a candidate does not get full marks for the online coding test, what are the chances of him or her getting a face to face interview? Just curious about the level of competition haha (This is because I'm not that worried about whiteboard interviews but afraid that I may not even get a chance to go through it)
|
||||
|
||||
I don't even think there's an online coding test for Facebook. Can't answer this.
|
||||
|
||||
### Would FB US hire SG citizens considering that there's an FB SG office already?
|
||||
|
||||
Yes.
|
||||
|
||||
### How I could improve my chances on landing an internship?
|
||||
|
||||
Study your DSA, grind LeetCode, do mock interviews with your peers to get used to talking out loud/communicating your thoughts while coding.
|
||||
|
||||
### I wanna learn as much as possible from you about topics that might benefit me
|
||||
|
||||
Benefit you in terms of what, and when? For passing the interviews, DSA and LeetCode. For the actual internship, that'll be a much longer answer which I shan't go into because that's a problem for later, if you pass the interviews.
|
||||
|
||||
### I heard FB doesn't ask dynamic programming questions, correct me if I'm wrong. Are there any topics I should be focusing more on?
|
||||
|
||||
I can neither confirm nor deny this. General tip for coding interviews - focus on the most common data structures and algorithms. If a particular topic is really obscure, most likely you won't be asked on it because asking obscure stuff sometimes work against the interviewers as it'd be harder for them to extract the right signals out of it. Look at the recommended practice questions in the handbook.
|
||||
|
||||
### How many rounds of interviews are there? Does FB ask system design on the live interviews?
|
||||
|
||||
For internships, typically two coding. For fresh grads, typically two coding with one behavioral. No system design for internships and fresh grad interviews.
|
||||
|
||||
### Would I be tested on specific tech stacks/real project experience, or is it purely algo based?
|
||||
|
||||
If you're applying for a SWE position, you won't be tested on a specific tech stacks/languages. The algorithm questions asked can be implemented in most programming languages (but you probably want to avoid using wenyan). If you're applying for a specialized position, then you might be asked to use domain-specific languages, which the recruiter should (will?) let you know ahead of time.
|
||||
|
||||
## Internship
|
||||
|
||||
### What are 3 qualities of a intern/new hire fellow FB engineers look out for?
|
||||
|
||||
This is a long answer and there are more than 3 qualities. But to get a conversion offer, in summary, interns have to show productivity and complete their assigned projects within the internship duration, product high quality code/work, demonstrate fast learning speed, actively communicate and collaborate, and show initiative and independence. Pretty much common sense if you ask me.
|
||||
|
||||
### What are the different types of internship roles that are opening in FB (both here in SG and overseas)!
|
||||
|
||||
IANACP. FB SG is quite limited in the sense we primarily only hiring SWE, EE interns. But I think I have seen TPM interns before. For overseas, almost every role is available.
|
||||
|
||||
### Are there machine learning/data science internship roles at Facebook SG? How about in other countries?
|
||||
|
||||
Not that I know of. Yes there should be for overseas, but then you'll be competing with a global pool of candidates.
|
||||
|
||||
### What does the SWE role entail? Tech stack and what to expect?
|
||||
|
||||
Software engineering of course. To answer seriously, it really depends on the team and their work. Most (all?) SWEs write code to solve problems. FB is big enough such that there are teams using almost every language out there.
|
||||
|
||||
Here's an oversimplified overview:
|
||||
|
||||
- Web Products - JavaScript/React/CSS/GraphQL/Relay/Hack (typed version of PHP)
|
||||
- Mobile - Objective-C/Java/React Native/Proprietary frameworks
|
||||
- Back End Services - Java/C++/Python
|
||||
|
||||
### What is the internship format in Facebook like? For example, are the interns inserted into a team to work on issues or are they handed a project to work on throughout their internship?
|
||||
|
||||
Under normal circumstances, interns would be given one project that should take them the entire internship duration (10 weeks or so out of a 12-week internship) to complete. They will be assigned an Intern Manager that would serve as their mentor throughout the internship. The mentor is typically the one who came up with the project which is broken down into multiple milestones. Responsibilities of an intern manager include: onboarding the intern, giving the intern regular feedback on how they are doing, reviewing their code (typically together with other members of the team), evaluating whether the intern will get a return offer.
|
||||
|
||||
### How's the mentorship like for FB interns? Do a mentor work together with intern on the same project? Are mentors randomly assigned within the company or do they volunteer for it?
|
||||
|
||||
Intern managers may or may not work with the intern on the same project, but they definitely should have context over the intern's project and be able to review (or at the very least, find suitable people) the intern's work. Employees can sign up to be an intern manager for a specific internship season. It is not random. It would be a disastrous and unpleasant experience for both the intern and the intern manager if an employee got randomly assigned to be a manager.
|
||||
|
||||
### What are some products that interns will get to work on in Facebook Singapore?
|
||||
|
||||
Intern projects are typically self-contained and achievable within the internship duration. Some example of intern projects in FB SG - rebuilding Oculus Accounts Portal (https://secure.oculus.com) using a modern React design system, building a self-serve order return flow into Oculus Accounts Portal. Outside of FB SG - Building the settings page of facebook.com, building an internal debugging tool (something like Redux Devtools).
|
||||
|
||||
### What kind of projects are interns usually given (like internal tooling or external products)
|
||||
|
||||
Answered above. Can be both, depends on the team. In Singapore, we primarily have product teams, so the projects are likely about adding product features.
|
||||
|
||||
### Will there be any chances of being transferred to an overseas office after being accepted as an intern?
|
||||
|
||||
Yes I know of that happening to some ex-interns. However, that could be due to special COVID circumstances which might not necessarily apply in following years. You'd have to check with the recruiter.
|
||||
|
||||
### How many interns is FB looking to onboard next summer? Not sure if this can revealed but thought I'll ask nonetheless
|
||||
|
||||
Don't know and even if I knew, I can't say. We had 4 interns in 2019 and around 10 interns in 2020. FB Singapore office is growing quite rapidly.
|
||||
|
||||
### I'm actually more interested in mobile dev, are there open internship roles for this in the SG office?
|
||||
|
||||
There are some teams in FB SG which work on mobile. Prior to starting internship at FB, interns will get to indicate their preference of tech stack and they will be matched to teams/projects which match their preferences.
|
||||
|
||||
### Do you get to try out different parts of engineering as an intern / junior swe in facebook? e.g. if I were doing back end but I would like to try front end later down the road
|
||||
|
||||
Short answer: for interns, not so much. For FTEs, much more autonomy.
|
||||
|
||||
Longer answer: Interns are assigned a project which usually have a pre-defined tech stack. So the engineering work and stack that an intern will be doing is highly dependent on the assigned team and project. If the intern finishes the work early, it's possible to ask for more work from their manager and possibly try out other things. If the internship duration coincides with one of the internal hackathons, interns can participate in them and work on anything they want. For SWEs, there's a process called bootcamp after joining where employees find their own team to join. That gives them more flexibility in deciding what kind of work they want to do. Internal mobility is very good within FB as well. Personally I've done both front end and back end at Facebook.
|
||||
|
||||
## FB Culture
|
||||
|
||||
### What's the difference between Software Engineer (SWE), Enterprise Engineer (EE), and Front End Engineer? This is because I heard from previous FB interns that they worked on the full stack.
|
||||
|
||||
- SWE - Generalists, they are expected to be able to work on software-related problem given to them and should be able to work across the stack.
|
||||
- EE - Taken from Facebook's Career Portal: "Facebook's Enterprise Products team is responsible for building integrated, scalable, and robust Enterprise Applications. As a member of Enterprise Products team, you will play a key role in re-imagining productivity by shipping transformative products that serve diverse aspects of the enterprise"
|
||||
- Front End Engineers - SWE with front end specialization. The interview is in HTML/CSS/JavaScript and there's more focus on domain-specific questions. That doesn't mean Front End Engineers can only work on front end stuff, they can work on anything as long as it is what their team needs and they have alignment with their manager. In my experience, Front End Engineers at FB are highly skilled in front end but can do back end work too. Btw I'm a Front End Engineer 😉
|
||||
|
||||
### What are the opportunities that are currently available for the FB SG office? And perhaps what kind of people do you typically look for? (e.g., in terms of technical skills or perhaps other metrics)
|
||||
|
||||
There are two main orgs in FB SG - Commerce Engineering and Ads & Business Products. The Commerce Engineering teams in Singapore build e-commerce websites to sell Facebook's hardware devices (Quest, Portal) and also sees through the rest of the lifecycle of a purchase - support center, returns, warranties. I'm in the Commerce Engineering org and my team manages https://www.oculus.com and https://portal.facebook.com. I don't know too much about the Ads side of things.
|
||||
|
||||
Read an [article about my manager, Nishita Agarwal](https://www.facebook.com/careers/life/help-10-peopleor-billions/), which mentions empathy as a key trait.
|
||||
|
||||
There's also an [article about Software Engineering in APAC](https://www.facebook.com/careers/life/software-engineering-in-apac) on the Facebook Careers blog.
|
||||
|
||||
### How is Facebook Singapore different from that at Hacker Way in San Francisco?
|
||||
|
||||
First and foremost, check out the following (old but still relevant) [article](https://vulcanpost.com/648705/facebook-singapore-office-marina-one/).
|
||||
|
||||
Nit - Hacker Way is not in San Francisco, it is in Menlo Park. Perhaps you meant SF Bay Area. Anyway, FB SG and FB US differ is quite a lot of ways. There are too many to list but I'll list the most obvious ones.
|
||||
|
||||
- Career Progression - FB US, being the HQ and where the company started, has the most number of teams and you have all levels of seniority of folks there. In FB SG, there are fewer teams and due to the size of the office now, there isn't a need for extremely senior engineers yet. So if you're talking about long term career progression, SG definitely loses out here. But don't need to think so far la, FB SG is still big enough for you to get to senior engineer position and earn enough to live comfortably for the rest of your life.
|
||||
- Projects - Primarily product teams and hires primarily SWEs and EEs, while FB US has a good mix of teams, including infrastructure teams and hires across all roles. So if you're interested in working on infra stuff like our internal logging framework, GraphQL, our internal ORM, you'd have to look at non-SG offices.
|
||||
- Changing Teams - SG has fewer teams, so if you were looking to change teams but remain in Singapore, the choices are more limited.
|
||||
- Company Culture - You don't get to attend the events held only at the HQ in-person, such as Zuck's Q&A or company town halls or the summer and holiday parties (but there are local versions of them).
|
||||
- Food - Smaller selection of cafes in SG. The food is still pretty darn good though. There's nothing to complain about free food.
|
||||
- Office - Smaller office in SG, but still one of the coolest in SG. Menlo Park Headquarters is amazing, there's an arcade, board games room, a barber, ice cream shop, a gadgets vending machine, and more. It looks like Universal Studios at night. I'll just leave this [video](https://www.youtube.com/watch?v=cY3sMN3wohg) here.
|
||||
- $$$ - FB pay is top tier in both US and SG. However in SG, you have to pay less tax and cheaper living expenses. In SG, I earn less but save more due to the large difference in taxes.
|
||||
- Taxes - SG tax is crazy low compared to US. US taxes you on every damn thing, including the capital gains from your stocks and bank interest earned (WTF), but SG doesn't.
|
||||
- Engineering Culture - Similar-ish because quite a number of engineers in FB SG moved here from FB US, including myself. But being a smaller office, we don't have as many extremely senior engineers.
|
||||
- Social Security - I thought Bay Area was relatively safer than the smaller US states, but these days [driving on the highway also can get shot](https://www.youtube.com/watch?v=0ybiHCxNb3w), so I don't know anymore. I think SG is definitely safer, at least you definitely won't receive any racist remarks or comments while walking on the streets.
|
||||
- Personal Happiness - Obviously you'd have fewer friends and family if you're in the US. If that's important to you then life there might be hard. But you can make new angmoh friends or hang out with the steadily growing SG community over there.
|
||||
- Dating Scene - If you're single, it might be hard to find a long-term partner there. The female Singaporean engineers there are mostly taken, those that are not, probably want to stay single. Dating there will be quite hard! I know of friends who got together with Americans/immigrants and then they get a green card and plan to stay there for good. You can consider that too.
|
||||
|
||||
I would describe myself as a small fish in a big pond when I was in FB US and am now a big fish in a smaller pond in FB SG. I enjoy my current work and team in FB SG and I see myself being in this role for a few more years at least.
|
||||
|
||||
### Are Facebook internal hackathons only within branches? Eg. only within FB Singapore?
|
||||
|
||||
They are kinda global in the sense that the timelines are global but each region has different people leading it for the regional offices. Participating teams will take part in the regional selection and winners of the regional ones come together to present to the global heads.
|
||||
|
||||
### What is the difference between Software Engineer and Front end Engineer at Facebook, and considering that my experience lies mostly in Front End Engineering, should I only be applying to the FE role?
|
||||
|
||||
Differences answered above. If you're solid in your Front End web fundamentals (HTML/CSS/JS), and suck horribly with DSA, I think you might stand a better chance going through the Front End interview loop. Unfortunately as of writing FB SG doesn't hire Front End Engineers so you'd have to look overseas for such a role.
|
||||
|
||||
### In the past one year, I have been hearing quite a lot of things about FB Reality Labs, and I heard that quite a significant portion of FB engineers are working on it now (and I think you are as well?)... do you have any thoughts about how it feels to work there and perhaps the future prospects?
|
||||
|
||||
I work on selling FRL hardware, not directly on FRL hardware/software itself. If you haven't heard of the [metaverse](https://www.theverge.com/22588022/mark-zuckerberg-facebook-ceo-metaverse-interview), you should read up about it. I don't have too many opinions on the future of FRL but I can say that Quest 2 is the market leader in terms of VR headsets and [Quest 2 was a major driver behind FB's $885 million 2020 Q4 non-ad revenue](https://www.roadtovr.com/zuckerberg-quest-2-mainstream-vr-headset-facebook-q4-2020-earnings/).
|
||||
|
||||
### What engineers is Facebook looking for - especially for New Grads? At the moment, I have knowledge on a breadth of tools but when asked on under the hood stuff, I can only explain what the tool / framework is trying to extract instead of going in depth as to how stuff actually works. Is the firm looking for new grad engineers who are language / tool / framework agnostic and can work towards building the skillset within the firm - or people who already have a speciality?
|
||||
|
||||
FB uses Flow (for JavaScript typechecking) and Hack (typed version of PHP) which most people outside of FB won't use. If we were to hire only people who have prior experience with them, then we'd have a really hard time filling our head count.
|
||||
|
||||
When tech companies hire SWEs, usually it's for a generalist position and they would expect the employees to pick up any new language or tool to get the job down. If you master your fundamentals, doing that shouldn't be too hard. So really most companies would want to hire people who can learn fast and adapt. The exception is if you're a super senior person (think principal level and above), then you'd be hired for your specialized skillsets probably because the company needs some subject-matter expert in that area. But most of you are still undergrads, that doesn't apply to you.
|
||||
|
||||
At the end of the day, many language and tools are similar-ish. New technologies learn from existing technologies and improve on them, learning new technologies isn't always that foreign.
|
||||
|
||||
However, to be a good SWE, I would recommend peeking beneath the abstraction layers and understanding what problem this technology is trying to solve, how it works under the hood, and what advantages/disadvantages it has compared to similar technologies. That's why I love Open Source, all the code is public - you can read the code, look at how the projects are structured, and even contribute to them. I also love reading articles comparing technologies so that I know what tradeoffs the projects are making and what's the right tool for the job. Don't be a mindless drone who uses technologies without knowing why you are using it instead of alternatives. That'll be an easy way to get phased out really soon, especially considering how fast technologies move.
|
||||
|
||||
### In my conversations with most engineers from US tech companies, I often hear that one of the major shortcomings of working in the Singapore offices is that they are more auxiliary in their functions, and that opportunities for "core" engineering work are few and far between. Since you have worked in both the Menlo Park and SG offices, I'd love to hear your response to this within the context of Facebook.
|
||||
|
||||
Answered above in the US vs SG comparison.
|
||||
|
||||
## Personal Experience
|
||||
|
||||
### Can I know about the project you're involved with in FB?
|
||||
|
||||
I'm currently working on a multi-year project which I can't reveal the details until we launch next year. Last year, I worked on Facebook's e-commerce websites - https://www.oculus.com and https://portal.facebook.com. I built design systems in React and a CMS framework to allow non-engineers to change the marketing content on oculus.com anytime they wish. One of the problems my team works on solving is to decouple marketing launches from engineering work, enabling the business teams to launch new products and campaigns on our e-commerce websites.
|
||||
|
||||
### Why did you choose front end engineering, and separately, how do you think the workload at Facebook compares to that of other "top" companies such as Google?
|
||||
|
||||
As a student I also liked to do design, so it was very cool for me to be able to implement my own designs on the web. That's why I chose to do client side engineering. As to why the web, I like the fast iteration and release cycle of building on web platforms. My first hardcore CS course was actually CS3217 (I only took CS1010E and CS1020E prior to that), so the first proper software I wrote was on iOS platform. Developing on mobile is too troublesome for my liking, because I often need a physical device, compiling the app takes so long, and you have to play by the platform's rules. They could take down your app anytime they want. On the other hand, the web is much more open and anyone can launch any website they want in a matter of hours. Being able to show people what I built by giving them a URL is an exciting experience that never gets old.
|
||||
|
||||
I haven't worked at Google so I can't comment on workload at Google. But Google is known as a good company to "rest and vest" whereas Facebook has faster promo cycles and rewards their top performing employees disproportionately.
|
||||
|
||||
### Am I correct to interpret that you started at Grab after graduation? What internships did you do during your studies?
|
||||
|
||||
Yes I worked at Grab for two years after graduation, you can check out my LinkedIn. Regarding university internships, Year 2 I did CVWO, Year 3 NOC in Silicon Valley for EasilyDo (now called Edison), Year 4 I was a Game Producer (non-programmer!) in SUTD Game Lab (previously MIT Gambit program). Back during my time, overseas internships weren't common. The number of Google and FB interns each year was fewer than 10.
|
||||
|
||||
### I'm also curious about what you do in your role as a Front End engineer, and why you decided to work at Facebook?
|
||||
|
||||
As a Front End Engineer at Facebook, I primarily write JavaScript and some Hack (PHP with types). Being at Facebook is fun because I get to do front end work which isn't product, such as building React-based design systems, front end tooling, lint rules, CSS frameworks (Infima), Static site generators (Docusaurus).
|
||||
|
||||
Facebook is the leader in terms of front end web technologies. If you develop on the web, you would more likely than not, be using some of Facebook's open source work, whether directly or not. There's React, Flux, Jest, GraphQL, React Native, Docusaurus, Draft.js, Relay, Flow, just to name a few. By working at Facebook, I also got the chance to work on Docusaurus and for two years, led the development of Docusaurus v2, which is one of the projects I am most proud of in my career. Today, Docusaurus is powering most of Facebook's open source websites. Many of the open source leaders I look up to were also at Facebook. I got to contribute to many high profile open source front end projects by Facebook and also work alongside the creator of React (Jordan Walke) on improving the front end of Facebook's Ads Interfaces. Not to mention that Facebook employees will be the first to dogfood React's new APIs and participate in design discussions and influence the future roadmap of React.
|
||||
|
||||
On the culture and working environment front, I have always vibed with Facebook's hacker culture and products more than Google's, so naturally I chose Facebook over Google even though their offers were comparable and I was given a chance to work on Google's search results page.
|
||||
|
||||
Facebook is the best place for a Front End Engineer to grow and learn from the very best. So it was the most obvious choice for me and I'm glad I made that decision. It's the best place I've worked at thus far (almost 4 years!) and also financially a great choice.
|
||||
|
||||
### Could I ask about your personal experiences at FB in terms of learning opportunities and the work you do? :)
|
||||
|
||||
The learning opportunities depend on many factors - individual preferences, team, projects, luck. Facebook is such a large company that covers virtually almost every domain of technology one can be interested in. With great internal mobility, it isn't hard to find a project that one will be passionate about. The benefits (and also downsides) of working at such a large company is that you often have to think about scalability in your work. How do you scale your work to the tens of thousands of engineers using your libraries or the billions of users using your product?
|
||||
|
||||
Facebook is also a company which takes the growth of employees very seriously. We have clear levels and expectations for engineers, supportive managers who really care about the growth of their team, mentorship programs available for anyone who wants to grow in a particular area. One of a manager's core responsibilities is to grow their team and employees, and they are being evaluated on that, so you can be sure that they treat it seriously. We have weekly 1:1s with managers and with our leads. Personally I'm mentoring around 3-4 junior engineers and helping them to grow into senior engineers in both their technical and organizational skills.
|
||||
|
||||
I've answered about my work above.
|
||||
|
||||
### What made you and the team came up with the idea of NUSMods and NUSWhispers? I think its really great to code for good and fulfilling stuff rather than coding for corporate means
|
||||
|
||||
I didn't come up with NUSMods. [Beng](https://nusmods.com/team) did. I helped to build features (my favorite being theming and dark mode), recruit members into the team, and also started the v3 rewrite which is the one you are using now. Most of the credit would go to [Yi Jiang](https://www.github.com/ZhangYiJiang), [Li Kai](https://www.github.com/li-kai) and [E-Liang](https://www.github.com/taneliang) for the current version. NUSMods code base isn't exactly that big, but it took us over a year of work to rewrite it on a modern stack.
|
||||
|
||||
Shout-out to [Christopher Goh](https://www.github.com/chrisgzf) for taking the helm now! Joining NUSMods was one of the best decisions in my life, as impacted the lives of so many students (I daresay above 100k), learnt so much from working on it (it's a relatively complex web application), and it helped me grow my network of like-minded individuals. **We need more people to contribute so that the project can live on.** Notice that the NUSMods core team (and alumni) have pretty zai backgrounds? Correlation or causation? Maybe both.
|
||||
|
||||
I came up with the idea for NUSWhispers but I didn't write much code for it. I was tutor for a web development course (CP3101B) back in 2015 and I proposed that idea to some students. I'm glad they did a darn good job of it. Back then I wanted to create a platform that could connect and help students around the school and the idea of an anonymous platform/page sounded like fun.
|
||||
|
||||
I like building stuff that people use, and after graduation I try to open source my stuff. This website you're reading now is also one of my largest open source work (in terms of popularity).
|
||||
|
||||
### I understand that you've been in FB for a couple of years, and worked in tech companies like Grab as well, given your prev/current experiences + what you've heard from fellow colleagues and peers, in your opinion what makes FB different from the other tech companies in terms of work done and how an entry engineer could expect to contribute?
|
||||
|
||||
I have only worked at two companies, so I wouldn't say I have seen a lot. But a few things stand out to me about FB as compared to other smaller companies:
|
||||
|
||||
- Top of the market compensation. It's really crazy a lot. Maybe not as much as quant trading firms, but if you also factor in other stuff like interesting work, social impact, then to me FB still comes up on top.
|
||||
- Bottom-up culture. In some companies, engineers are treated like mindless drones and expected to just execute. But not at FB. At FB, engineers are expected to do a fair bit of product and project management, propose ideas and lead the roadmap for their team, especially if their team's product is a highly technical one. We have lots of flexibility and autonomy to manage our own work and what we want to do with our time. As someone who has many ideas and likes to build them, it suits me well.
|
||||
- Lots of responsibilities given. FB trusts you to do the right thing. You could technically bring down facebook.com on your first day of work if you were careless (or evil).
|
||||
|
||||
### How do you run your team? This question is relating to the culture you foster within your own team.
|
||||
|
||||
We have very few processes. My team is excellent so I trust them to do the right things and they don't disappoint. In my current multi-year project, I broke it down into smaller parts and pieces and assigned them to my teammates according to their interests and expertise. I set the guidelines and some general engineering principles, make sure my team is aware of them and we stick to them when developing. We set goals for the half and then we're pretty much running the project each on our own. On a day-to-day basis, I spent about half my time writing code and the other half reviewing code and attending meetings. I'm also mentoring a few engineers and I guide the newer engineers more and provide them with constant feedback on technical work and behavioral changes that could help them to grow.
|
||||
|
||||
### How has Facebook impacted your career in terms of learning and growth and since you probably have many FANG companies to choose from, what is Facebook unique selling point to you personally?
|
||||
|
||||
By working at Facebook, I got to see how large engineering teams operate at scale, how products are developed and launched to millions of users, and learn from the very best engineers in the world.
|
||||
|
||||
Front end and open source. I answered in more detail above.
|
||||
|
||||
### Are most of the projects at Facebook internal tools for the company or more for the public/users? Or does this depend on the team you work at?
|
||||
|
||||
There's a good mix. Yes it depends on location as well. Most infra teams and in the bigger engineering offices (US, London). Singapore is still new and growing rapidly.
|
||||
|
||||
## Career
|
||||
|
||||
### I'd like to seek your advice on what I should be prioritizing in my next two years of school in order to gain relevant skills/experience to stand out to FB recruiters when I graduate.
|
||||
|
||||
Work on being a good engineer who has mastery of the fundamentals. Good grades, impressive internship experiences, side projects, etc are important but only for getting the interview. At the end of the day it doesn't matter how much your CAP is if you can't answer the interview questions, which boils down to your mastery of the skills needed to being a SWE. Do things that you are interested in AND also benefits you.
|
||||
|
||||
### Just wanted to hear your opinion on how much emphasis I should place on personal projects, grades, LeetCode, hackathons/coding challenges, job experiences, CCA involvement, etc.
|
||||
|
||||
This is a hard question to answer because everyone is different. Some people are just born smart and don't have to study much and still get their grades. Some people are just not cut out for studying, but are great at building impactful side projects. Know your comparative advantage and leverage it. Personally, I could probably do back end work if I tried hard enough but I just don't enjoy doing it. I leverage my passion for design and attention to detail to build user interfaces and related tooling instead.
|
||||
|
||||
Strike a balance between breadth and depth. As undergrads, you can have a lot of room to explore and also relatively low stakes environment to fail. Take this chance to try out a lot of things, then choose what you really like and are good at. You can specialize after you have tried out enough things and know what you want and are good at. I've tried out back end, mobile, game development and prefer front end development the most.
|
||||
|
||||
By now you should know that not every investment reaps the same level of rewards. CCAs which aren't related to CS can be fun, widen your social circle and improve your soft skills. If that's important to you, by all means go ahead. But if you suck at programming, and spend all your spare time on random CCAs which doesn't help you in your craft, then you'll probably end up as a mediocre programmer. Back in school, I never really had an official CCA - I chose to do tutoring, work on open source stuff like NUSMods, and working as a boarding councillor at NUS High (sort of like RA but for NUS High Students), which gave me free accommodation near school). I liked the balance and diversity of the activities I had.
|
||||
|
||||
My CAP isn't that high - got first class but not near 5.00. I reckon I could get A+ for every module if I really spent all my time studying, but studying isn't exactly my favorite activity to do. I got my As usually from modules which were project-heavy. I value and enjoy the hands on experience more than the mugging experience.
|
||||
|
||||
I'm very lucky that Software Engineering exists so that there's something meaningful which I can spend my time on, I enjoy doing, and also pays the bills.
|
||||
|
||||
### I want to learn as much as possible from you about topics that might benefit me as I'm graduating next year.
|
||||
|
||||
DSA. No DSA mastery, no passing of interviews, no Facebook job offer.
|
||||
|
||||
---
|
||||
|
||||
**_I am not a recruiter and I might have answered some of the recruiting or internship-related questions wrongly, so take them with a grain of salt. Opinions expressed are my own and do not represent the views of my employer._**
|
||||
36
apps/website/blog/2021-08-28-front-end-career-questions.md
Normal file
36
apps/website/blog/2021-08-28-front-end-career-questions.md
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: Front End Career Questions
|
||||
slug: front-end-career-questions
|
||||
author: Yangshun Tay
|
||||
author_title: Engineering Lead at Facebook
|
||||
author_url: https://github.com/yangshun
|
||||
author_image_url: https://github.com/yangshun.png
|
||||
tags: [front end, career]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
Recently a junior front end engineer at a startup in Singapore reached out to me to ask me how front end development as a career.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
<head>
|
||||
<link rel="canonical" href="https://yangshuntay.com/blog/front-end-career-questions/" />
|
||||
</head>
|
||||
|
||||
### My manager told me that currently it's a bit hard to define requirements & expectations for higher tier / higher Individual Contributor (IC) level for Front End engineers in the organization. Since you are working at Facebook, I am wondering what are some requirements & expectations for higher IC level there for Front End engineers (maybe around IC4, IC5 and above if that's kinda the level you use there)?
|
||||
|
||||
For smaller companies that might be true, but it's still possible if you don't limit yourself to front end work. Going up the levels is all about scope and complexity. IC3s (Junior Engineer) work on tasks, IC4s (Software Engineer) work on features, IC5s (Senior Software Engineer) work on projects, IC6s (Staff Software Engineer) work on huge projects spanning across teams, IC7s (Senior Staff Software Engineer) work on projects spanning across the org, IC8+s (Principal Software Engineer) work on projects spanning across the company or even influencing the industry. If you're able to show that you can handle scope of that magnitude, there shouldn't be a reason not to be compensated at that level. That said, the rough guide I proposed here is for a company the size of Facebook where we have 10s of thousands of Engineers. Doing work that impacts an entire company of 10 people likely won't be IC8 level work. For reference, React core team is mostly made up of IC5s/IC6s and one IC7. Flow has a number of IC5s and IC6s as it's technically complex and affects how the entire company writes JavaScript. GraphQL has many senior engineers and the creator of GraphQL is currently a director (IC8 equivalent).
|
||||
|
||||
### Are you still doing a lot of Front End-related development work now? Be it in the company or personally? If yes, I am just curious what are the things you often do, and what do you like in particular about Front End development?
|
||||
|
||||
I'm still doing a lot of Front End development for work. Less in a personal capacity ever since I stopped working on Docusaurus as a side project. You can check out my GitHub to see what stuff I've done. At work I'm in-charge of oculus.com and built the infra for it. I built a design system of React components for the content developers to develop the marketing pages.
|
||||
|
||||
I really like all aspects of Front End development, maybe except optimizing performance. At FB we build a lot of Front End-related tooling (e.g. Jest, GraphQL, Flow) and libraries (our internal CSS-in-JS solution, Docusaurus, React, Flux, etc) which is personally very exciting to me. Even within front end development, there are various layers - very user-facing stuff (HTML/CSS/visual related code) and back end (JavaScript stuff, network layer, storage), tooling (ESLint, Babel, TypeScript, webpack). I call myself a full front end stack developer as I'm decent across the entire front end stack. I'm especially excited about tooling work as the problems there are interesting and challenging. Typically only large companies face such problems because they only occur at scale, hence I really like being at FB because FB is one of such companies.
|
||||
|
||||
### Personally, do you have any tips on how best to grow as an Front End engineer? Are there any particular areas that you'd recommend?
|
||||
|
||||
Learn your fundamentals well. There are many UI and CSS libraries out there, but a good Front End developer still needs to know how to build a website without them. Peek beneath the abstraction layers and understand the problems these libraries are trying to solve, do not use them blindly. Keep building stuff - try to build a simple version of the libraries you frequently use, build interesting user interfaces and products, etc.
|
||||
|
||||
### What do you think about developing breadth-wise vs depth-wise? For example, do you think it's important for a software engineer to know more about other fields besides the end he/she is currently working at? In particular, what do you think about an Front End engineer that knows BE (i.e. a full-stack developer), or an Front End engineer that knows mobile development (with the advent of React Native or Flutter)?
|
||||
|
||||
I somewhat answered this in another [blog post](/blog/are-front-end-development-skills-enough-for-a-career). Lemme know if your question isn't answered after reading it.
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
title: Resume improvement case study
|
||||
slug: resume-improvement-case-study
|
||||
author: Yangshun Tay
|
||||
author_title: Engineering Lead at Facebook
|
||||
author_url: https://github.com/yangshun
|
||||
author_image_url: https://github.com/yangshun.png
|
||||
tags: [career, resume]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
import TeikjunResumeOldURL from '@site/static/img/teik-jun-resume-old.png'; import TeikjunResumeNewURL from '@site/static/img/teik-jun-resume-new.png';
|
||||
|
||||
As an example of putting the Resume tips to practice, let's reviewing [Teik Jun's](https://github.com/teikjun) resume, critiquing it and improving it. At the time of writing, Teik Jun is a Year 4 undergraduate at National University of Singapore and is looking for a Software Engineering (SWE) internship for the summer of 2022.
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
Here's the initial version of Teik Jun's resume I received from him.
|
||||
|
||||
<div className="text--center">
|
||||
<figure>
|
||||
<img alt="Teik Jun's initial resume" className="shadow--md" src={TeikjunResumeOldURL} />
|
||||
<figcaption>Teik Jun's initial resume</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
On first glance, it looks like a solid resume, and it is. However, I've known Teik Jun for a few years now since the [Major League Hacking (MLH) Fellowship program](https://fellowship.mlh.io/) where he [contributed a ton of features to Docusaurus v2](https://github.com/facebook/docusaurus/commits?author=teikjun), and know that he has done even greater things in the past. This version of his resume doesn't do his skills justice. Let's see how we can improve it by applying the points learnt in the previous section.
|
||||
|
||||
## Resume critique
|
||||
|
||||
### Good
|
||||
|
||||
- Demonstrates diverse and full stack experience - Has experience in front end, building web applications, JavaScript tooling, payments infrastructure and blockchain
|
||||
- Diverse interests and abilities - Open Source, AI and Machine Learning, Front End, Algorithms TA, Hackathons
|
||||
- Clean formatting which is easily readable
|
||||
- Reverse chronological order
|
||||
- Straightforward, bullet point format
|
||||
|
||||
### Points of improvement
|
||||
|
||||
- **Irrelevant experience** - It's honestly super cool to be "Best Shot" of Sniper Course and to get other impressive accolades as an NSF, but it's hardly relevant to a SWE job. If I were running out of space I'd remove it.
|
||||
- **Not sufficiently conveying the impressiveness of his experience** - Teik Jun's work on the MLH program was for a popular Facebook Open Source project, Docusaurus (the same project that powers this website) and he did very very good work as part of the program. I know because I reviewed his Pull Requests and he did a damn good job. Docusaurus is an important project to Facebook and widely used by popular Facebook projects like React Native, Jest, and Relay.
|
||||
- **Not explaining what the project is about** - In most cases, recruiters are the ones reading a resume and they would not know what a project is about, especially when most of them aren't technical. Hence resumes also have to explain the complexity and impact of a project. I know what Docusaurus and TEAMMATES are, but that's because I worked on Docusaurus and I am aware of NUS' projects. Most recruiters would not, so we have to explain what they are. TEAMMATES was also a Google Summer of Code project, so mentioning that would be nice.
|
||||
- **Trivial details** - Under TEAMMATES, there was a point "Added a progress indicator component for expensive operations". This sounds quite small and can be removed if there's a lack of space.
|
||||
- **Obscure projects** - The "Mentorship Management Web Application" doesn't sufficiently relay the complexity. The details are also obvious and doesn't sound impressive. I'd remove this project because it doesn't add much value.
|
||||
- **Contributions to Open Source projects** - Any project can be made open source and contributing to your own open source homework doesn't mean much. What makes open source contributions impressive would be the complexity of the project and the contributions made. The latter might be hard to fit into a resume, so we should do the former at the very least.
|
||||
|
||||
### Bonus
|
||||
|
||||
I know that Teik Jun will be interning with ByteDance in the fall, so it could be added as a signal of Teik Jun's abilities, telling recruiters that he's good enough to work at ByteDance.
|
||||
|
||||
## Improved version
|
||||
|
||||
Here's an improved version of Teik Jun's resume which I feel which better highlights Teik Jun's abilities. Main changes made were:
|
||||
|
||||
- Added more important keywords - ByteDance (future internship), Facebook (MLH collaboration), Google (TEAMMATES was a Google Summer of Code project for a few years).
|
||||
- Removed redundant and unimportant details.
|
||||
- Added links to certain projects to make it more convenient for recruiters who want to gain more context of the projects listed.
|
||||
|
||||
In my opinion, this improved resume is sure to capture the eyes of any recruiter in the world!
|
||||
|
||||
<div className="text--center">
|
||||
<figure>
|
||||
<img alt="Teik Jun's improved resume" className="shadow--md" src={TeikjunResumeNewURL} />
|
||||
<figcaption>Teik Jun's improved resume</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
@@ -0,0 +1,157 @@
|
||||
---
|
||||
title: A Glimpse into Front End Interviews
|
||||
slug: a-glimpse-into-front-end-interviews
|
||||
author: Kai Li
|
||||
author_title: Software Engineer at Stripe, ex-Quora
|
||||
author_url: https://github.com/li-kai
|
||||
author_image_url: https://github.com/li-kai.png
|
||||
tags: [front end, leetcode]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
A glimpse into the front end interview process and questions that frequently come up.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
<head>
|
||||
<link rel="canonical" href="https://lik.ai/blog/a-glimpse-into-front-end-interviews" />
|
||||
</head>
|
||||
|
||||
## Interview Process
|
||||
|
||||
Applying for front end engineer roles is very similar to software engineer roles, but the interviews can be quite different. In my experience, for each company, there tend to be between 3 to 4 sessions. Most of them will be testing on JavaScript and discussion around web development technologies, and the rest on algorithms or behavioral.
|
||||
|
||||
One aspect that I have found interesting is that the younger the company, the more questions will lean towards JavaScript. This could be because hiring specifically for front end engineers is relatively new. Older companies used to only hire software engineers without regard if their focus is on the back end or front end.
|
||||
|
||||
## JavaScript Rounds
|
||||
|
||||
JavaScript is the main focus among all the companies I have interviewed with. It makes sense as front end work nowadays is very JavaScript-heavy. HTML and CSS knowledge is no longer a necessity thanks to component libraries and the likes.
|
||||
|
||||
### JavaScript Minutiae
|
||||
|
||||
To qualify for some companies, you might need to brush up on the minutiae of JavaScript. Topics like variable hoisting, holey arrays, non-strict mode, and switch case fall through came up. While I do not feel that knowing such things determine who is a better engineer, it is what it is. Here is my [JavaScript cheat sheet](https://repl.it/@li_kai/JavaScript-Cheatsheet).
|
||||
|
||||
### JavaScript Topics
|
||||
|
||||
After the first assessment, live interviews tend to test on more advanced JavaScript concepts such as the event loop, promises, async/await, scope and closures.
|
||||
|
||||
If you have been writing JavaScript applications for some time and have come across a variety of situations, this should not be too hard.
|
||||
|
||||
The most frequently asked question I have ever gotten is to implement `debounce` and `throttle`:
|
||||
|
||||
```javascript
|
||||
function debounce(fn, duration) {
|
||||
let id;
|
||||
return function (...args) {
|
||||
if (id) {
|
||||
// reset timeout and prevent it from triggering
|
||||
// if debounced function is called within duration
|
||||
clearTimeout(id);
|
||||
}
|
||||
id = setTimeout(() => {
|
||||
fn(...args);
|
||||
}, duration);
|
||||
};
|
||||
}
|
||||
|
||||
function throttle(fn, duration) {
|
||||
let id;
|
||||
return function (...args) {
|
||||
if (id) {
|
||||
// if throttled function is called within duration,
|
||||
// do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
fn(...args);
|
||||
|
||||
id = setTimeout(() => {
|
||||
id = null; // release "lock"
|
||||
}, duration);
|
||||
};
|
||||
}
|
||||
|
||||
// usage example
|
||||
const helloWorld = () => {
|
||||
console.log('hello world');
|
||||
};
|
||||
const debouncedHelloWorld = debounce(helloWorld, 1000);
|
||||
const throttledHelloWorld = throttle(helloWorld, 1000);
|
||||
```
|
||||
|
||||
The second most frequently asked question is to implement a sequential `Promise.all` of sorts:
|
||||
|
||||
```typescript
|
||||
function sequential(data, fetcher) {
|
||||
const helper = (index, results) => {
|
||||
if (index === data.length) {
|
||||
return results;
|
||||
}
|
||||
return fetcher(data[index]).then((datum) => {
|
||||
results.push(datum);
|
||||
return helper(index + 1, results);
|
||||
});
|
||||
};
|
||||
|
||||
return helper(0, []);
|
||||
}
|
||||
|
||||
// usage example
|
||||
const fetcher = (i) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => resolve(i), 1000);
|
||||
});
|
||||
};
|
||||
sequential([1, 2, 3], fetcher);
|
||||
```
|
||||
|
||||
## Discussion Rounds
|
||||
|
||||
### Web development tools
|
||||
|
||||
Regardless of how we wish to deny it, web development tools are an increasingly complex and diverse ecosystem.
|
||||
|
||||
Smaller companies, especially start-ups, require engineers who have a good understanding of these tools. Larger companies will be able to abstract tooling complexity away from engineers unless the role demands it.
|
||||
|
||||
As such, web development tools like Webpack and Babel have become a common discussion topic.
|
||||
|
||||
A good understanding of tools like Webpack would be to be able to explain the following concepts:
|
||||
|
||||
- what is bundling
|
||||
- what is tree-shaking
|
||||
- what is lazy-loading and why does it matter
|
||||
- how loaders work
|
||||
|
||||
### React or web framework of choice
|
||||
|
||||
If the role states that React knowledge is required, you may be expected to answer or code out React components. If you do not have React experience, using other frameworks would be possible, provided that you can explain well what is happening.
|
||||
|
||||
This may range from implementing a feature live or simply answering or explaining some React concepts such as `useEffect`'s dependencies array or `shouldComponentUpdate`.
|
||||
|
||||
### Work experience
|
||||
|
||||
Aside from the two topics mentioned earlier, interviewers might dive into one or two things that they found interesting in your resume and ask you to elaborate.
|
||||
|
||||
As I had some experience in writing Babel plugins and jscodeshift code mods, I walked them through how I utilized those tools to help make the company codebase better.
|
||||
|
||||
## Implementation Rounds
|
||||
|
||||
In all of my interviews, I have only been asked to implement a feature twice. It is not a common question, but it may come up.
|
||||
|
||||
This would come down to how well-versed you are with your basics such as HTML and CSS, as well as tools and frameworks. As an example, one of the question I have gotten was to implement an autocomplete search bar like Google's. If you have built something like that before, it is doable within an hour.
|
||||
|
||||
Implementation rounds feel very similar to algorithms, as you need to actively find the best solution while thinking out loud and explaining your decisions.
|
||||
|
||||
## Algorithm Rounds
|
||||
|
||||
As software engineers, we are not unfamiliar with algorithm questions. LeetCode and Hackerrank are common resources used for practicing such questions.
|
||||
|
||||
As I knew this was my weakness, this was where I spent the most time. It may be a little ironic that I chose Python over JavaScript as my language of choice for tackling algorithms. JavaScript's lack of a native minheap and binary search implementation made it a slightly worse choice.
|
||||
|
||||
For those who are just starting to learn Python or getting back into it, here's my [Python cheat sheet](https://repl.it/@li_kai/Python-Cheatsheet).
|
||||
|
||||
## Conclusion
|
||||
|
||||
Front end software engineer roles are not very different from general software engineer roles, but they do tend to be more specialized and in some ways, require even more effort.
|
||||
|
||||
If you are passionate about this field and interested in what you do, this would not be too high of a hurdle. I hope my experience and tips were useful to you, and good luck in your search!
|
||||
@@ -0,0 +1,107 @@
|
||||
---
|
||||
title: My Experience Working as a Meta (previously Facebook) Engineer
|
||||
slug: my-experience-working-as-a-meta-facebook-engineer
|
||||
author: Yangshun Tay
|
||||
author_title: Engineering Lead at Meta
|
||||
author_url: https://github.com/yangshun
|
||||
author_image_url: https://github.com/yangshun.png
|
||||
tags: [career, facebook, meta]
|
||||
image: /img/meta-facebook.jpg
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
A number of the folks I referred have completed their interviews and are in the midst of deciding which company's offer to accept for their internship/full-time roles. Hence I figured it might be a good time to write about my experience at Meta (previously Facebook) so far as it could be helpful in helping some of them make their first important career decision!
|
||||
|
||||

|
||||
|
||||
**Disclaimer: Opinions are my own and do not represent the views of my employer (Meta)**
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
## Products
|
||||
|
||||
Meta is a huge company and has teams working on all sorts of products. For big tech companies, common products include ads networks, chat, enterprise offerings, video watching, payments, hardware products, industry-leading AI tools, internal tools, etc. the other big tech companies Microsoft, Amazon, Apple and ByteDance have products in some of these areas as well. For many big companies, they are large enough that they build their our own infra and internal tools for most technologies they use because most existing technologies on the market can't meet their scale. Hence, not only will you get the chance to work on consumer products, you might also get to work on some of the lower level infrastructure work that is used by your fellow software engineers - our internal database systems, our internal Docker, our open source projects like React, React Native, GraphQL, Jest, PyTorch, Docusaurus, etc.
|
||||
|
||||
The impact is huge - every line of code you write has the potential to impact millions (sometimes even billions) of users due to the widespread nature of Meta's products. There was an intern who on their second day of work, changed the placeholder text of facebook.com's search bar by accident to "Hi I'm a Search Bar!" as part of a ramp up task and it was shipped to public for a brief moment before the change got reverted. With great power comes great responsibility!
|
||||
|
||||
### Teams in Meta Singapore
|
||||
|
||||
Let's talk about some of the teams in Meta Singapore since I currently work in Singapore and many of the readers are based in Singapore. **Note that this section will go out of date as priorities shift. Last update: 2022/05/12.**
|
||||
|
||||
In Meta SG we have two teams belonging to two organizations - Commerce Engineering and Ads & Business Platform. Both organizations, like most organizations in Meta, have global impact where the number of users is in the order of millions or more.
|
||||
|
||||
Commerce Engineering (hardware sales) is Meta's next up and coming revenue stream and is also the organization which I work in. Commerce Engineering primarily deals with bringing Meta's hardware products to market - from building immersive digital storefronts and highly optimized checkout flows to delivering great post-sales experiences to platforms that manage the demand, production, testing and shipping of Meta hardware products across the entire supply chain. If you have heard of the Quest headset device, which is Meta's flagship VR device, my team spent the entire of 2021 building the Meta Store website to sell them (https://store.facebook.com/quest/ and https://store.facebook.com/portal/). I led the organization's migration from our existing separate Meta Quest and Portal websites to the unified Meta Store website, by building the web infrastructure, the React components for the web version of the Meta Store Design System, and developed migration guides + new APIs to help teams quickly migrate their products onto the Meta Store website. In April 2022, Meta announced the [Meta Store in Burlingame, California](https://about.fb.com/news/2022/04/meta-retail-store/) and the Meta Store website, which is one of the most visible products from the Singapore engineering office. It's definitely one of the highlights of my career to be building a product that contributed to Meta's 2nd highest revenue stream (and still growing)! We have even bigger plans for the Meta Store website. Stay tuned.
|
||||
|
||||
Some stories from engineers in Commerce Engineering:
|
||||
|
||||
- [Help 10 People—or Billions? Engineering Impact on a Global Scale](https://www.metacareers.com/life/help-10-peopleor-billions/), Nishita A., Software Engineering Manager, Commerce Engineering
|
||||
- [Embracing Change to Evolve Her Engineering Journey](https://www.metacareers.com/life/embracing-change-to-evolve-her-engineering-journey), Michelle T., Software Engineer, Commerce Engineering
|
||||
|
||||
On the Ads and Business organization, there are these teams:
|
||||
|
||||
- **Business Integrity**: They work on building tools to catch bad advertisers (advertisers who create ads which violate our policies). They want to maximize Business Integrity outcomes by building a human review system for ads & commerce on Meta, driving end-to-end improvements in the workflows, and providing best-in-class tools to IP rights holders, etc.
|
||||
- [Software Engineering in APAC: Building for Rapid Growth](https://www.metacareers.com/life/software-engineering-in-apac)
|
||||
- [Curiosity and Passion: Software Engineering at Facebook](https://www.metacareers.com/life/curiosity-and-passion-software-engineering-at-facebook), Henry B., Software Engineer, Business Integrity
|
||||
- **Business Support Platform**: They redefine the support experience across all Meta business products, making it available, effective and effortless for all businesses. They make sure businesses can identify the help resources available to them when they need assistance in accomplishing their goals across Meta's suite of business tools. Their tools will also effortlessly help marketers diagnose their issues and connect them to the best solution to solve their problem. They have also some investment into the machine learning space.
|
||||
- **Business Messaging Commerce**: They build products that enable the Business Messaging ecosystem across Messenger, Instagram, and WhatsApp.
|
||||
|
||||
Enterprise Engineering has a sizable presence in Singapore as well:
|
||||
|
||||
- [Enterprise Engineering in APAC: Building Products That Scale](https://www.metacareers.com/life/enterprise-engineering-in-apac)
|
||||
- [Opportunity and Trust: Growing an Engineering Career at Meta](https://www.metacareers.com/life/opportunity-and-trust-growing-an-engineering-career-at-facebook), Shuhong W., Enterprise Engineering Manager
|
||||
|
||||
## Career progression/compensation
|
||||
|
||||
Meta is one of the best companies for ambitious people who want to grow their careers quickly. At Meta, promotions come sooner and we encourage employees to be at their top form. At Meta, our terminal level (level at which there is no pressure to promote) is E5 and most people get from E3 to E4 within 1-1.5 years and from E4 to E5 within 2-2.5 years (this is a conservative estimate - I've seen top performers go from E3 to E5 in under 2 years). As an E5 in Meta SG your annual compensation will be at least 300k annually, which is on par, if not higher than most director-level roles in non-tech industries in SG. Imagine getting to that level of pay within 5 years of your career!
|
||||
|
||||
For comparison, Google, which is a similar company to Meta in many ways, has a slower promotion cycle - the average engineer at Google takes more than 2 years to get from L3 to L4, more than 3 years to get from L4 to L5 and more than 4 years to get from L5 to L6. At Google the terminal level is L4 so there's no pressure to promote. None of my peers are L6 at Google but a few are already E6 at Meta and it is quite achievable.
|
||||
|
||||
Faster promotions also lead to better pay, so in most cases, Meta pays more than most other companies. Meta is one of the top companies in terms of reputation and prestige especially for engineers.
|
||||
|
||||
## Company prospects
|
||||
|
||||
Meta is a tech giant and their products have over 3 billion active monthly users. The company relies on ads as their primary source of revenue. Whether you like it or not, Meta products are around to stay for the next couple of years. Even if they are going to die off, it won't be that soon. Stock growth has been relatively strong over the past few years (doubled since I joined in Nov 2017), especially since 2020.
|
||||
|
||||
Mark Zuckerberg is also betting on the [Metaverse](https://about.fb.com/news/2021/10/founders-letter/), which is obvious from the decision to change the company name from Facebook to Meta. Personally I'm undecided on whether the Metaverse is the future.
|
||||
|
||||
## Culture
|
||||
|
||||
There's so much to say about a company's culture, but hopefully you can infer some things about the company culture from the stuff I wrote above. Since I am an engineer, I will speak more about the engineering aspects of Meta's culture.
|
||||
|
||||
- Done is better than perfect - At Meta we have a quote "Done is better than perfect". Shipping something into the hands of users is more important than having perfect engineering. Teams get to decide how they want to build their products, whether to focus on getting MVPs out first and then iterating and improving the engineering later on, however they want.
|
||||
- Bootcamp - Many engineers at Meta aren't assigned a team before they start at the company. They have to go through this program called Bootcamp, which is a crash course to teach them the useful tools and practices and also match them to their future team. Bootcampers work on Bootcamp tasks, which are small tasks created by various teams across Meta to get acquainted with the tech stack, development flow, and also the various products Meta has to offer. Few weeks into the Bootcamp program, bootcampers start chatting with managers of teams and can choose to work with teams which interest them. Bootcamp ends with the bootcamper decides on a team to join. Bootcamp is a great way for new employees to find teams which interest them the most and lowers the risk of them joining a team that aren't a good fit for them.
|
||||
- Development efficiency - There are tens of thousands of Software Engineers at Meta, hence we have teams specializing in making the developer experience extremely efficient for us. The default IDE for us is a customized version of VS Code with a ton of useful internal plugins. Engineers can each get a remote server to do development on, which contains the latest code and development environment set up - we can start coding right away without having to figure out how to update dependencies and set up the necessary environment.
|
||||
- Bottom-up culture - Engineers at Meta get a lot of say regarding the roadmap and wear multiple hats - project roadmapping, project management, data analysis, prototyping, etc on top of the core coding expectations. I'm personally heavily involved in the roadmapping process for my team as my team has a heavier focus on engineering - we build tools for the other product teams within Commerce Engineering to use.
|
||||
- Hackathons - Hackathons have been an integral part of Meta's culture since it started and many successful products were born out of hackathons. Hackathons are a great way to encourage innovation and promote collaboration between engineers, designers, product managers, etc. In the past, the most successful hackathon projects get shipped - Like button, Facebook timeline, comments tagging. These days, due to the maturity and scale of the company, shipping hackathon projects to the public is rarer but our hackathon culture is still going strong. In a recent hackathon, me and two others built a Kudoboard replacement to solve a problem faced by managers where they had to resort to external services in order to sign group cards to send well wishes to coworkers (farewell/celebrating work anniversaries). We took a weekend to build an initial version of a tool we uncreatively call "Boards", spent the next week or so integrating with internal features like commenting, reactions, GIFs and announced about it in a company-wide group. The response was very encouraging - it has gained significant traction within the company - over 2000 boards and 20000 messages have been written since it was launched in Aug 2021! As a bonus, we'll be getting credit for it in our performance review :)
|
||||
- Building cool internal tools - At Meta scale, it sometimes make sense for us to build our own internal tooling that has tight integration with our internal ecosystem as opposed to using an external service which might incur significant expenses and also pose security risks. We have teams building and maintaining our own tasks tool, code browsing and reviewing tool, a Q&A tool similar to Stack Overflow, a customized version of VS Code, an interview question bank, interview feedback tool, data visualization and querying tool, and a workflow automation tool similar to IFTTT/Zapier! Someone built a Pokedex app where you can catch a random Pokemon every time you close a task (I'm at 807/899 now!). I also have to mention that we have an internal meme maker which we can use to add customized internal memes to use in our comments in diff reviews and group posts
|
||||
- Code wins arguments - It's not gender, race or your background that wins debates, it's the work that you produce. Instead of spending time arguing over technical decisions, it is more convincing to write some code to demonstrate the point.
|
||||
- Beyond coding - We are also expected to contribute to the company beyond our coding, as in our perf evaluation we have a People axis, which measures how much you help and grow the people around you. People give talks, organize events, summits, do interviews, to score in this axis.
|
||||
- Fun social groups - Workplace is Meta's enterprise offering, it's essentially Facebook for companies. We have various interest groups where we can find colleagues to play board games, share cat photos, memes when we want to procrastinate on writing performance reviews, interesting puns, investing tips, and more!
|
||||
|
||||
## Mentorship and growth
|
||||
|
||||
Mentorship is readily available at Meta all the way from interns to senior executives. One thing that stood out to me when I first joined Meta was the focus on mentorship. When I first joined the company and was in the Bootcamp program, I had a Bootcamp mentor. After joining a team, I was assigned a senior engineer as my mentor who was also my tech lead. Employees will have weekly 1:1s with their mentor and manager. For interns, each intern at Meta is assigned an intern manager, who will act as their mentor and is usually the person who came up with their internship project. The intern manager will be the main person evaluating the intern's work and they ultimately determine the intern's performance and if they receive a return offer at the end of their internship.
|
||||
|
||||
These days, as a tech lead myself, I have around 4 1:1s weekly with mentees and 2 with managers. I'm able to chat with my mentees and mentors about anything - it doesn't have to be about work. I often give my mentees feedback on how they are doing, advice and ideas on how they can be more successful, talk about the things I'm working on and why I made certain decisions.
|
||||
|
||||
There are also specialized mentorship programs for those who need it, technical mentorship, career growth mentorship, managerial role transition mentorship, etc.
|
||||
|
||||
## Work-life balance
|
||||
|
||||
At Meta, you get to choose how fast you want to accelerate your career. Some people choose to take up more responsibilities, work more and ship more impact, usually resulting in faster professional growth, higher ratings and pay, while others work at their own comfortable pace; it's really up to the individual. The top performer on my team now is nearly getting to E5 with just around 2 years of working experience. They don't work beyond working hours, they're doing well because they're working smart and working on the most impactful and challenging problems.
|
||||
|
||||
Every Meta employee has 21 days of leave/paid time off every year and this year the company gave everyone three company-wide paid holidays on Friday in the summer and also two Meta choice days - effectively more paid time off but they cannot be accrued.
|
||||
|
||||
## Transfers and mobility
|
||||
|
||||
It is extremely easy to move around in Meta because Meta understands that mobility is important to the happiness and welfare of employees. People move around quite often and people are eligible to consider team changes from their second year at the company onwards. Meta is a large company comprising of many organizations and each organization has their own unique culture. It can be refreshing to move to another part of the company, working on different domains, different products, experiencing a slightly different engineering culture, yet still be productive because you are using the same engineering tools as before. When engineers move around the company, positive things can happen - they bring the good practices from their previous organizations to the new organizations, networks are strengthened and new connections are formed. Because Meta has offices around the globe, it is also possible to transfer to different countries as long as there are no work authorization issues. Personally I relocated back to Meta Singapore office after working for 2 years in Meta Menlo Park and my manager has worked in **4 different offices** (Menlo Park, London, New York, Singapore) throughout her 9 years at Meta!
|
||||
|
||||
For engineers, there are also temporary transfers which we call Hackamonths. Hackamonths are month-long projects proposed by teams where they welcome someone outside their team to work on. At the end of the hackamonth, the participating engineer could return back to their original team or stay on the new team. This provides engineers with the opportunity to try out work and the culture of their new teams before committing to a permanent move.
|
||||
|
||||
## What I dislike about Meta
|
||||
|
||||
- Imposter syndrome - The company is full of the smartest people in the world. There are many days I feel that the people around me are smarter than me and that I might not belong here.
|
||||
- Launch processes - With the company undergoing tons of scrutiny these days, we have to be even more careful around how we use our users' data and what we are tracking. Every public launch now has to undergo a review process with legal and security.
|
||||
- Cross-timezone collaboration - My team frequently works with product managers, designers and other roles who are based in California. Meetings with these folks tend to be in the morning (their evening) and it can be hard to get up in the morning sometimes...
|
||||
- Fewer low hanging fruits - In a mature company especially if you are working on mature products, sometimes the low hanging fruits have been snapped up and you mostly are left with really tough problems to solve. On the bright side, Meta engineers should be smart and should be able to live up to those challenges.
|
||||
- Legacy code - Unless you're working on a new product, you inevitably will have to be deal with code others have written. The older the product you work on, the more legacy code you have to deal with and the code quality varies.
|
||||
@@ -0,0 +1,107 @@
|
||||
---
|
||||
title: Front End vs. Back End System Design Interviews
|
||||
slug: front-end-vs-back-end-system-design-interviews
|
||||
author: Zhenghao He
|
||||
author_title: Senior Software Engineer at Instacart, ex-Amazon
|
||||
author_url: https://twitter.com/he_zhenghao
|
||||
author_image_url: https://pbs.twimg.com/profile_images/1489749168767660032/M_us3Mu2_400x400.jpg
|
||||
tags: [front end, back end, system design, interview]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
Walkthrough of similarities and differences between front end vs. back end system design interviews and my thoughts on a front end career ceiling.
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
<head>
|
||||
<link rel="canonical" href="https://www.zhenghao.io/posts/system-design-interviews" />
|
||||
</head>
|
||||
|
||||
## Context
|
||||
|
||||
As I mentioned in my post on [coding interviews frameworks](https://www.zhenghao.io/posts/framework-for-coding-interview), I have been interviewing a lot for the past year - not conducting interviews, I was the candidate being interviewed. Most of the interview processes I had with big tech companies consisted of 1-2 system design rounds depending on the level of the role. Unlike traditional back end-focused system design questions, for which you can find lots of prep resources online such as the famous Grokking System Design Interview or System Design Primer, I didn't know what to expect for a front end-focused system design interview as there are very few resources out there talking about this type of interviews.
|
||||
|
||||
Now that I have done a fair amount of system design interviews of both types, I want to give you a summary of what to expect, especially for the front end ones since I have been mostly working on the front end side.
|
||||
|
||||
## Similarities
|
||||
|
||||
Both front end-focused and back end-focused system design interviews share a lot of similarities in terms of the methodology you can adopt to solve the design questions:
|
||||
|
||||
- Starting with gathering system requirements
|
||||
- Laying out a clear plan and identifying major distinguishable components of the system
|
||||
- Proceeding to end to end api design
|
||||
- Talking about optimization
|
||||
|
||||
Other kinds of similarities include:
|
||||
|
||||
- The interviewer is relying on you to drive the presentation. You can't rely on the interviewer to have your back.
|
||||
- While the topics can be either micro or macro, you probably won't need to actually write code - it is rare to jam some portion of coding in the middle of a system design interview
|
||||
- Unlike scantron school exams, both types will consist of mainly open ended questions. There probably isn't a checklist of things for you to cover one by one. Nor are you expected to drill deep into all of those. When you realize your interviewer is biased toward a particular part of the system, which they usually do, pivot your focus to that area. Other times you focus on your strengths and lead the conversation.
|
||||
|
||||
## Differences
|
||||
|
||||
During the back end-focused system design interviews, you would spend most of the time talking about things like:
|
||||
|
||||
- Back end/server side architecture, hand waving various back end services/components
|
||||
- Discussing which type of database to use and how to aggregate data across different shards
|
||||
- Designing SQL table schema
|
||||
- Choosing the right the cross-region strategy if your service has a global user base
|
||||
- Any other kinds of system characteristics like latency, availability, fault tolerance, etc
|
||||
|
||||
For front end-focused system design interviews, you would spend most of the time talking about stuff like:
|
||||
|
||||
- Front end/client side architecture, such as the appropriate rendering pattern to choose - client side rendering, or server side rendering or static generation or something in between?
|
||||
- What kind of data fetching mechanism to use - REST vs. GRAPHQL vs. gRPC and what should the APIs look like?
|
||||
- Specifics about UI components
|
||||
- A news feed which has an infinite scroll behavior with all the images lazily loaded while ensuring the client side has the aspect ratio of the images upfront to prevent layout shift.
|
||||
- An autocomplete UI component which fetches search result data incrementally in batches while receiving images from server pushes in parallel.
|
||||
- a gallery page which pulls images and displays them in the correct order despite the asynchrony that comes with the network requests that might cause them to arrive out of order.
|
||||
- How do you leverage different layers of cache to decrease latency or support offline mode.
|
||||
- If they want to get framework-specific, which is totally possible, they might even ask you to define a particular React components's props or manage complex state in a React app.
|
||||
|
||||
A lot times having one type of system design interviews means you can over simplify the opposite side:
|
||||
|
||||
- In a back end system design interview, the client-side/front end is reduced to an API layer - you don't need to consider all the intricacies of the browser or the pesky rerenders your real-time updates would cause.
|
||||
- In a front end system design interview, you can treat the back end as a black box and you don't need to worry about how things like how to scale a database, or how your choice of using web sockets might affect the load balancers because of the need for sticky sessions support.
|
||||
|
||||
But again, this is a summary of my experience and depending on who your interviewers are (are they front end, back end and/or fullstack developers), the scope of the role and which team it is (are you going to be on a front end team or are you expected to work across the stack and stretch into the back end?) your front end system design interview might be a bit of a hybrid where some aspects of back end system design interviews might come up.
|
||||
|
||||
Outside of the differences with the technical topics I needed to dig deep into during the interviews, I found there are two other interesting differences that stand out between the two types:
|
||||
|
||||
- For front end system design interviews I was often encouraged to treat the interviewer as the **product manager** and we spent some time just fleshing out the brief solution for each user story. For the back end system design interviews, we didn't really get to talk about any user interaction (I am aware that the definition of users of your system might vary, depending on whether it is customer-facing vs. developer-facing)
|
||||
- These two types of system design interviews also differ a lot in terms of estimating certain system's needs based on the potential scale of the system. The system needs can be storage needs or throughput needs or any other types of requirements.
|
||||
- It is common and expected to do these estimation during back end system design interviews since your design decision is only feasible when all of the system needs can realistically be met.
|
||||
- But for the front end system design interview, I rarely needed to do any **quantitative estimation** - for example, when I was designing some live feed during a front end system design interview, I didn't need to do estimations like "So let's say each message was roughly 140 characters long and it is utf8 so that's 140 bytes and an average user gets 10000 messages over a certain period of time so we ended up allocating 1.4mb memory on user devices". Again, I am not saying that this would never come up during a front end system design interview. in my experience It is just much, much more rare compared to back end ones.
|
||||
|
||||
## Career ceiling
|
||||
|
||||
I am going to talk about something that is a little tangential. I don't think this is going to be a hot take but if you just want to pass the upcoming interviews, then you are welcome to skip this part.
|
||||
|
||||
I have done interviews for both front end focused roles and general software engineer roles. As I went through the preparation process for the system designs interviews, it just occurred to me that there is indeed a career ceiling for a pure front end focused software engineer role.
|
||||
|
||||
Ok so let's first get this out of the way - you can be extremely successful as either a front end developer or a back end developer.
|
||||
|
||||
Also it is hard to discuss any topic intelligently when we cannot agree on definitions. By saying front end developers I meant developers/engineers who solely work on the UI of a software system. And by saying career ceiling I meant the potential terminal title and the highest level such a developer/engineer can achieve in the technical individual contributor track.
|
||||
|
||||
This is an unspoken thing and a very impolite conversation. And [there are exceptions](https://twitter.com/swyx/status/1236023548227072000) to this but just statistically speaking there seems to be a career ceiling for front end-only developers.
|
||||
|
||||
## Fighting the inertia
|
||||
|
||||
Part of the ceiling comes from some traditional baggage:
|
||||
|
||||
- modern front end development is fairly new compared to the back end counterpart. I have seen some bias in the industry that front end is not real engineering compared to the back end and that needs absolutely to be combated.
|
||||
- power structure persists for a very long time and that's partially why most of VP Eng and CTOs out there are back end/infra developers.
|
||||
|
||||
## Economic reasoning
|
||||
|
||||
I had this realization that when I was going through the back end system design interviews vs. the front end system design interviews - the technical topics those interviews tend to cover let me think about some economic reasoning leading to the perception of a "Front end ceiling" as well. Your value to the company really depends on how many machines/compute/storage run through you. As a developer/engineer, that means much money you control and front end-only developers just don't take as much. Of course front end is just as hard and as important especially for consumer facing products but at the end of the day your compute is being run on someone else's machine or device and the company just don't value that as much as the compute that they themselves need to pay for and to scale.
|
||||
|
||||
## Short-lived vs. long-running
|
||||
|
||||
On top of that, normally the front end/web apps are short-lived on the client side - the user opens the browser tab that loads your app and after 20 minutes they might just close the tab, and all the memory allocated by your app is on their devices from that point onward. On the other hand, the back end servers/services behind probably keep running for months or even years. One implication resulting from this difference is that you can generally get away with bad code that leads to performance problems down the road in front end apps because they are short-lived and the scale of the data they are dealing with is probably small, but you cannot ignore that in a long-running back end service.
|
||||
|
||||
Good luck with your interviews.
|
||||
|
||||
---
|
||||
|
||||
_Follow me on [Twitter](https://twitter.com/he_zhenghao)_
|
||||
@@ -0,0 +1,197 @@
|
||||
---
|
||||
title: Take Control Over Your Coding Interview
|
||||
slug: take-control-over-your-coding-interview
|
||||
author: Zhenghao He
|
||||
author_title: Senior Software Engineer at Instacart, ex-Amazon
|
||||
author_url: https://twitter.com/he_zhenghao
|
||||
author_image_url: https://pbs.twimg.com/profile_images/1489749168767660032/M_us3Mu2_400x400.jpg
|
||||
tags: [interview]
|
||||
---
|
||||
|
||||
## The interview question
|
||||
|
||||
Imagine you were a university student looking to land an entry-level software engineer job and you were having this technical coding interview. The interview question starts with a table showing amount of units of a product sold at the shop and the corresponding price per unit. The idea here is that there is an incentive for customers to buy in bulk – the more we can sell the lower the price:
|
||||
|
||||
```
|
||||
purchase quantity price per unit
|
||||
1-5 5 dollars
|
||||
6-10 4 dollars
|
||||
11-20 3 dollars
|
||||
20+ 2.5 dollars
|
||||
```
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
<head>
|
||||
<link rel="canonical" href="https://www.zhenghao.io/posts/take-control-coding-interview" />
|
||||
</head>
|
||||
|
||||
The task the interviewer asks you to do is to write out a function that takes the amount of the times being purchased as the input and output the price per unit according the table. So if the input is 5, the function returns 5, and if the input is 6, the function returns 4... you get the idea.
|
||||
|
||||
That's it. That is the whole question. "This is even simpler than [Fizz Buzz](https://leetcode.com/problems/fizz-buzz/)," you think to yourself, "but it might lead to more difficult follow-up questions, like it might get tweaked into a binary search problem or something". So you start to write the following simple solution, expecting more in-depth follow-up questions to come.
|
||||
|
||||
```js
|
||||
function getPrice(amount) {
|
||||
if (amount >= 1 && amount <= 5) return '5';
|
||||
if (amount >= 6 && amount <= 10) return '4';
|
||||
if (amount >= 11 && amount <= 20) return '3';
|
||||
if (amount > 21) return '2.5';
|
||||
return 'unknown price';
|
||||
}
|
||||
```
|
||||
|
||||
However, to your surprise, after you came up with this solution, the interviewer just stops there, moves on to the next question or discusss something completely unrelated.
|
||||
|
||||
The next day, you get a rejection letter from the company.
|
||||
|
||||
## The Tweet
|
||||
|
||||
This is based off of a true story. It was a real interview question and the solution I wrote above was considered **unacceptable** by the interviewer, i.e. the tweet author.
|
||||
|
||||
<blockquote class="twitter-tweet"><p lang="zh" dir="ltr"><a href="https://twitter.com/hashtag/%E5%BE%AE%E4%BB%A3%E7%A0%81?src=hash&ref_src=twsrc%5Etfw">#微代码</a> 最近面试校招生的一个感想:有非常多的同学会写出解法1的代码,这让我很难理解。以至于只要看到有解法2的样子,印象上就会先加分了。 <a href="https://t.co/g38d2A5Bjj">pic.twitter.com/g38d2A5Bjj</a></p>— toobug (@TooooooBug) <a href="https://twitter.com/TooooooBug/status/1437252082264731649?ref_src=twsrc%5Etfw">September 13, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
||||
|
||||
A while ago this tweet went viral in the Chinese programming circle. The tweet author used this exact question to screen new grads for an entry-level software engineer position. The tweet and the question were written in Chinese so I translated this question into English.
|
||||
|
||||
In the tweet, he complained that he was having a hard time understanding (很难理解) why many students came up with the solution that we came up with above. Instead of a straightforward solution with a bunch of `if` statements, he said he was expecting an answer like this:
|
||||
|
||||

|
||||
|
||||
Compared to the first solution with a bunch of `if` statements, this solution, in his opinion, is more **modular, extensible, and maintainable**. That was the answer he had in mind and failing to arrive at this solution means you are weeded out in the interview process.
|
||||
|
||||
I am not sure how you feel about this, but in my opinion, this is a pretty pointless interview question to ask new grads. The first solution is totally fine. Under the right circumstances, the second solution is closer to what you would want in production code, even though it is still not quite the [table-driven development](#table-driven-development) you'd want.
|
||||
|
||||
There are so many things I want to unpack, so here is the tl;dr:
|
||||
|
||||
1. Different types/styles of interviews call for different answers and that should be clearly communicated during the interview. The first solution is totally fine as the answer to an algorithmic question.
|
||||
2. Take control of your interview so you don't have to guess what the interviewer has in mind. You do this by asking clarifying questions. **Keep asking until everything the interviewer is looking for is clear to you**.
|
||||
3. The table-driven method (what the second solution tries to achieve) **optimizes for changes** and that's why the interviewer (the tweet author) failed students who didn't come up with that answer.
|
||||
|
||||
The overarching theme in this post is that you should take control of your coding interview so you don't have to guess the answer your interviewer is thinking of.
|
||||
|
||||
## Different styles of interviews calls for different answers
|
||||
|
||||
Generally, there are two types of coding interviews:
|
||||
|
||||
1. Interviews that focus on **algorithms & data structures**
|
||||
2. Interviews that focus on **practical app/feature-building** and test your hands-on engineering chops
|
||||
|
||||
Normally it should be easy to distinguish between these two types of interviews by merely looking at the question: [Inverting a Binary Tree](https://leetcode.com/problems/invert-binary-tree/) is a typical algorithmic question, while designing and implementing an auto-complete search feature is more about practical app-building. Although sometimes the two types of interview questions would blend. For example, you might be asked to (partially) implement a [trie](https://en.wikipedia.org/wiki/Trie) when you are talking about the design of an auto-complete search feature/service/component. But these two different types of interviews are meant to test different competences.
|
||||
|
||||
In a pure algorithmic, LeetCode-type of interviews, your **main goal** is to leverage the right data structures and come up with an efficient algorithm to solve the problem with the right set of memory/runtime complexity trade-offs **as fast as you can**. How readable, maintainable and extensible your code is, or whether it conforms to the current best practice in the the community/industry are _not_ that important, or at least secondary to the main goal. You can go ahead and name your variables `i`, `n`, `p`, `q` and mutate that input array in-place without being judged as long as your solution passes the test cases under the time and memory limits.
|
||||
|
||||
> As [Joel Spolsky](https://www.joelonsoftware.com/) wrote in his [blog post](https://www.joelonsoftware.com/2006/10/25/the-guerrilla-guide-to-interviewing-version-30/): with the algorithmic interview questions, he wants to see if the candidate is smart enough to "rip through a recursive algorithm in seconds, or implement linked-list manipulation functions using pointers as fast as you can write on the whiteboard".
|
||||
|
||||
For more experienced engineers/developers, the coding interview tends to lean into the practical app-building category, where **readable, maintainable code and extensible program structure** are what they look for, and all aspects of the full software development life cycle, even including error handling, are fair game to be asked, as they are important in real-world software building.
|
||||
|
||||
Here I don't make any value judgment about which type of interviews are good or better. I just pointed out that they exist and interviewers look for different things by conducting different types of interviews.
|
||||
|
||||
### Take control over the interview
|
||||
|
||||
As an interviewee, you want to make sure you understand **which category the question falls into** because the underlying core criteria on which you are assessed are different – you don't want to overload the capacity of the working memory of your brain with tasks that are secondary before you reach the main goal. You want to take control over the interview so you are not left in the dark.
|
||||
|
||||
One way to take control over the interview is to **narrate your thoughts** as you go and **articulate any assumptions** you have to make sure you get confirmation from your interviewer on your way forward or they should help you correct course.
|
||||
|
||||
If I were the candidate receiving this exact question, I would ask this upfront: "should I write production-grade code with good engineering practices or you are more interested in how I'd tackle the algorithm & data structure part?". That is probably one of the highest ROI questions we can ask during an interview. The interviewer would either tell me to write a workable solution under the constraints of the runtime or space characteristics or treat this as a real-world engineering problem with real-world tradeoffs.
|
||||
|
||||
### With all that being said, it is a bad question to ask new grads
|
||||
|
||||
The question itself doesn't test any of the core competencies that distinguish between brilliant programmers and mediocre ones. What's really being tested here, based on the (ideal) answer the interviewer (the author of the tweet) had in mind, is the whether the candidate – **new CS grads** without any significant experience working in the software industry – knows how to use the table-driven method to implement such a function.
|
||||
|
||||
I don't believe that any smart college student who can breeze through a graph traversal problem in an interview can't understand and pick up patterns like the table-driven method in just a couple of hours. On the other hand, any mediocre programmers who happened to read _[Code Complete](https://en.wikipedia.org/wiki/Code_Complete)_ can write a table-driven solution and pass the interview. Not to say that knowing good engineering practices is not a good thing; it is just that using that as the **only** hiring criteria to hire new grads is pointless and it doesn't help you find the smart kids.
|
||||
|
||||
<details>
|
||||
<summary>So what are the ideal interview quetsions to ask new grads?</summary>
|
||||
|
||||
Joel pointed it out [in his post](https://www.joelonsoftware.com/2006/10/25/the-guerrilla-guide-to-interviewing-version-30/) that the ideal interview questions should cover at least one of these two Computer Science concepts: 1. recursion 2. pointers
|
||||
|
||||
I actually agree with him on this. You want to ask questions about these two concepts not because they are ubiquitous in your average codebase and you have to use them every day. It is because they are a great tool to test the ability to reason and think in abstractions, the kind of mental aptitude a brilliant programmer would have.
|
||||
|
||||
</details>
|
||||
|
||||
Anyway, the moral of the story is don't be afraid to ask clarifying questions so you don't have to guess what the interviewer looks for and cares about if they are not being explicit about their expectations.
|
||||
|
||||
> You can stop here if you don't care about technical discussions about this simple interview question.
|
||||
|
||||
## Table-driven development
|
||||
|
||||
Solution 2 resembles a form of table-driven development described in a classic programming book called _[Code Complete](https://en.wikipedia.org/wiki/Code_Complete)_. But even if you have never read the book, you probably know this pattern from your experience working as a software developer/engineer.
|
||||
|
||||
At its core, it tries to separate **data** from **logic**: instead of having all the information about pricing strategy (the data) hardcoded in the function (the logic) as literal values, it separates them.
|
||||
|
||||
The pricing strategy is a business rule, and business rules tend to be the source of frequent changes. By encoding that in an external data structure (i.e. the array `priceMap` in this case), we make our program easier to accommodate future changes. Whenever the pricing strategy changes, we can just modify the entries in the array without touching the logic of the function. In other words, we isolate the unstable part, so the effect of a change will be limited.
|
||||
|
||||
However, I said it only resembles table-driven development that you'd use in production code but it is not quite there yet:
|
||||
|
||||
1. The pricing data is not fully separated from the logic as the array `priceMap` is still defined within the function
|
||||
2. Magic numbers are still there
|
||||
|
||||
Depending on where the pricing data comes from, one possible variation of the table-driven method for this particular question is as follows:
|
||||
|
||||
```javascript
|
||||
// config.js
|
||||
export const priceByRanges = [
|
||||
{ min: 1, max: 5, price: '5' },
|
||||
{ min: 6, max: 10, price: '4' },
|
||||
{ min: 11, max: 20, price: '3' },
|
||||
{ min: 21, max: Number.MAX_SAFE_INTEGER, price: '2.5' },
|
||||
];
|
||||
|
||||
// app.js
|
||||
import { priceByRanges } from './config.js';
|
||||
|
||||
function getPrice(amount) {
|
||||
// error handling for amount outside the range
|
||||
return priceByRanges.find(
|
||||
(priceByRange) => amount >= priceByRange.min && amount <= priceByRange.max,
|
||||
).price;
|
||||
}
|
||||
```
|
||||
|
||||
Now the pricing data is stored in `config.js` seperately and `priceByRanges` is resolved at load time.
|
||||
|
||||
### Further optimization
|
||||
|
||||
If the array `priceByRanges` is always sorted in terms of the price ranges, we can further optimize Solution 2 by leveraging binary search.
|
||||
|
||||
```javascript
|
||||
const priceByRanges = [
|
||||
{ min: 1, max: 5, price: '5' },
|
||||
{ min: 6, max: 10, price: '4' },
|
||||
{ min: 11, max: 20, price: '3' },
|
||||
{ min: 21, max: Number.MAX_SAFE_INTEGER, price: '2.5' },
|
||||
];
|
||||
|
||||
function getPrice(amount) {
|
||||
if (amount < priceByRanges[0].min) {
|
||||
return 'unknown price';
|
||||
}
|
||||
|
||||
let start = 0,
|
||||
end = priceByRanges.length - 1;
|
||||
|
||||
while (start <= end) {
|
||||
const mid = (start + end) >>> 1;
|
||||
if (priceByRanges[mid].max < amount) {
|
||||
start = mid + 1;
|
||||
} else {
|
||||
end = mid - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return priceByRanges[start].price;
|
||||
}
|
||||
```
|
||||
|
||||
<details><summary>What is this <code>>>></code>?</summary>
|
||||
|
||||
`>>>` is binary right shift by 1 position, which is effectively just a division by 2 followed with a `Math.floor`. e.g. for 11: 1011 -> 101 results to 5.
|
||||
|
||||
</details>
|
||||
|
||||
### Notes on performance and Big O
|
||||
|
||||
It might feel that the first clumsy solution with a bunch of `if` blocks is better in terms of the performance than the second table-driven approach that _loops_ through the array.
|
||||
|
||||
Actually for the Big O analysis, both approaches have the **same constant time complexity**, as the number of operations (i.e. comparision between `amount` and the price range), doesn't grow no matter how big the input is (i.e. `amount`).
|
||||
|
||||
What's more interesting, in my opinion, is the performance implications between using a loop vs. "unrolling" the loop. By unrolling I mean discretely writing line-by-line of the loop body. [A quick google search](https://stackoverflow.com/questions/38111355/javascript-are-loops-faster-than-discretely-writing-line-by-line) suggests that popular JavaScript engines such as V8 heavily optimize loops. But getting any accurate results from such a micro-benchmarking is really hard as the performance varies a lot depending on different factors like the engine and the code in the loop body.
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
title: Why You Should Include Debugging In The Interview Process
|
||||
slug: why-you-should-include-debugging-in-the-interview-process
|
||||
author: Zhenghao He
|
||||
author_title: Senior Software Engineer at Instacart, ex-Amazon
|
||||
author_url: https://twitter.com/he_zhenghao
|
||||
author_image_url: https://pbs.twimg.com/profile_images/1489749168767660032/M_us3Mu2_400x400.jpg
|
||||
tags: [interview, debugging]
|
||||
---
|
||||
|
||||
<br />
|
||||
|
||||
:::tip
|
||||
|
||||
See discussions on [Hacker News](https://news.ycombinator.com/item?id=31125269)
|
||||
|
||||
:::
|
||||
|
||||
## Most technical interviews are over-indexing on coding
|
||||
|
||||
Over the past two years, I have interviewed with over 10 different tech companies ranging from hot startups like Coinbase, Stripe, and Instacart to FAANG companies like Amazon and Meta, for Software Engineer positions of various levels.
|
||||
|
||||
The technical interview processes I have had all consisted of at least two rounds of coding interviews, where I either had to solve an **algorithmic, LeetCode-type** question or build a **practical app/feature**. During those coding interviews, I always started with an _empty slate_: if it was an algorithm-heavy interview question, there would be a literally empty file in the editor for me to start writing code; if it was a practical app building exercise, there might be some boilerplate code or some utilities/helper functions available but still I was expected to build the app/feature from scratch.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
I do think they did a good job at assessing my coding ability. But the issue I see here is that the standard interview process in our industry has over-indexed on coding ability along. As a software engineer, apart from meetings and writing design docs, I’d say at least half of my programming work isn’t just coding – the other half largely involves searching through a codebase and reading existing code or code-adjacent artifacts like error messages, tests, and logs. And oftentimes, coding isn’t the hardest part.
|
||||
|
||||
## What is programming exactly
|
||||
|
||||
Programming is a complex task so it makes sense to dissect it so we can study the different phases, dimensions and components of it individually.
|
||||
|
||||
I have been reading [_The Programmer's Brain_](https://www.manning.com/books/the-programmers-brain) by Felienne Hermans. It is a book about the cognitive process involved in programming. Felienne divides programming into five more concrete activities: **searching, comprehension, transcribing, incrementation, and exploration**.
|
||||
|
||||
Searching is the activity where a programmer is looking for a specific piece of information in a codebase, such as the precise location of a bug you need to fix in the code.
|
||||
|
||||
Comprehension is reading the code to understand its functionality and the way it is intended to work. It also involves executing the code and observing the results.
|
||||
|
||||
Transcribing is about converting your thoughts or solutions to executable code. This is what we usually refer to as **"coding"** and is what the current standard coding interview process only focuses on.
|
||||
|
||||
Incrementation is about incrementing (iterating) on an existing codebase, such as adding a new feature. It is a mix of the previous activities, where a programmer has to search, comprehend and transcribe their thoughts to code.
|
||||
|
||||
Exploration is sketching and prototyping with code. Try things and use code as a means of thought. It is also a mix of the previous activities.
|
||||
|
||||
With this newfound knowledge, it is not hard to tell what exactly the current standard interview process lacks. Activities such as searching and comprehension are completely left out and you have no way to prove your competencies needed for a big part of a software engineer job.
|
||||
|
||||
It begs the question of what we can do to complement the interview process to cover all these activities. And the answer is to add a **debugging interview** in the process.
|
||||
|
||||
## Debugging is all-encompassing
|
||||
|
||||
When one is debugging, they engage in **all five activities**. It entails a sequence of searching, comprehension, exploration and writing code. And it is incredibly revealing to watch one debug:
|
||||
|
||||
1. Are they debugging with a plan, iteratively bisecting the code or just randomly tweaking the code?
|
||||
2. How are they navigating their way through an unfamiliar codebase, forming different hypotheses about the bug?
|
||||
3. Do they try to write a test that reliably reproduces the issue?
|
||||
4. Are they able to find where things are diverging and trace to the root cause?
|
||||
5. Are they familiar with the IDE or editor they are using and know how to use tools like breakpoints and watches to step through the code?
|
||||
6. Do they understand how to read error messages and leverage stack traces?
|
||||
7. Are they able to implement a fix at the end?
|
||||
8. ...the list goes on and on
|
||||
|
||||
On top of its comprehensiveness, debugging is what software engineers do on a regular basis. It is relevant to the actual work.
|
||||
|
||||
Out of all the companies I have interviewed for, _only_ Stripe conducted a debugging interview. They call it Bug Squash, where you’d dive into a large, well-written library codebase to fix real-world open-source bugs. I had a blast going through that interview which I can’t say about boring LeetCode questions.
|
||||
|
||||
Granted, preparing such a debugging interview involves more work for the company than just throwing a LeetCode question at the candidate. Still, having that in the process gives you more signals for selecting capable, experienced engineers. I hope more companies start to embrace that in their hiring process.
|
||||
|
||||
## Further reading that can make you better at debugging
|
||||
|
||||
- [_Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems_](https://www.goodreads.com/book/show/3938178-debugging) by Dave Agans
|
||||
- [_Debugging Software_](https://blog.isquaredsoftware.com/2021/06/presentations-debugging-software/) by Mark Erikson
|
||||
- [_How I got better at debugging_](https://jvns.ca/blog/2015/11/22/how-i-got-better-at-debugging/) by Julia Evans
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
title: Getting a Tech Job as an Undergraduate
|
||||
slug: getting-a-tech-job-as-an-undergraduate
|
||||
author: Melody Yun
|
||||
author_title: RCG Software Engineer at PayPal
|
||||
author_url: https://github.com/caramelmelmel
|
||||
author_image_url: https://github.com/caramelmelmel.png
|
||||
tags: [undergraduate, career, job search]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
Recently, I have met many juniors and peers especially from non-computer Science related backgrounds asking me about securing a job as a fresh graduate especially in this area of software engineering. Here's my take and some tips and tricks to get started.
|
||||
|
||||
<!--truncate-->
|
||||
|
||||
Before I share my resources and how to get a gentle start on this handbook, let me warn you that you would need to allocate a minimum of 6 months to get really good and confident with some of the LeetCode questions. Do not neglect the behavioral questions too! I am not going to repeat some of the things that are mentioned in this handbook but rather help everyone with some useful shortcuts of mine to navigate this resource to ease your preparations.
|
||||
|
||||
## Crafting your resume
|
||||
|
||||
In most companies, the resume stage is the most important as it is the first stage that you will need to clear! For undergraduates, most hiring managers would only look at resumes that are within one page. The moment the second page is seen, they will not tend to consider. Hence, here are some tips that can help you to prepare your resume in under an hour to reduce your agony.
|
||||
|
||||
1. Use a <strong>career hiring tool</strong> like [Kinobi](https://app.kinobi.asia/resume). Kinobi saves you time in having to fix alignments unlike word as this career tool formats everything for you. Furthermore, they help you to score your resume so that you know where you stand when applying for a job.
|
||||
|
||||
2. As far as possible, <strong>attend career talks</strong> by your favorite companies because hiring managers are there and you can get some feedback about your resume. It is indeed helpful because you know what to look out for when applying.
|
||||
|
||||
3. Keep your sentences short and sweet, else you are out of the game.
|
||||
|
||||
- <strong>Good example:</strong> "Developed a full-stack website that garnered positive responses from faculty and administration about course visualization." You need not provide tech stacks and let alone, links here. The sentence here is short and sweet and all in past tense.
|
||||
|
||||
- <strong>Bad example:</strong> "Was a project manager for two projects- AI_ducation as well as the lift project for ALEF. Helped day-to-day operations by communicating with clients in Mandarin to map business requirements to technical requirements.". Over here, the sentence is long and things can be <strong>separated out into points</strong>. Furthermore, it does not describe the outcome of the project enough to say <strong>"Why should you be hired?"</strong>.
|
||||
|
||||
4. To save time, while building your projects, apply good practices and also think of various optimizations in terms of algorithmic design, not forgetting system design. You can also show this off and this saved me a lot of time especially when it comes to grinding LeetCode.
|
||||
|
||||
5. Your LinkedIn stands out the most and less of your personal website unless it's design related or frontend related. Write more things that are still succinct on your LinkedIn. Show your work there and let recruiters interact with your work.
|
||||
|
||||
6. ATS-friendly resumes are the most important ones as recruiters screen high volumes of candidates everyday so they have less than even 5 seconds to look at your resume. Some companies use ATS to scan for good keywords.
|
||||
|
||||
## How to use the Tech Interview Handbook easily
|
||||
|
||||
I am about to recommend relevant sections to go in sequentially and how to systematically use them to your advantage especially in being real productive. This stage is normally faced when the resume stage has passed. Even then, months of prior preparation has to be done. However if you only have one month to prepare, I suggest the following tips:
|
||||
|
||||
1. Know your interview process. Ask your recruiter about the interview process.
|
||||
|
||||
2. Go to your Glassdoor page and pick out some of the past relevant interview questions that your company has done to get a gauge of what to expect. If you are unable to do those past questions, I suggest revising a good amount about the common topics. One common topic is array and hash table design. You can refer to the [coding interview rubrics section](/coding-interview-rubrics/) get to know your interview rubrics. It helps and you know what to do.
|
||||
|
||||
3. Know and try various techniques for each LeetCode question. It's not purely about variety but more about if you were to even come back to the same question, will you be able to give a more optimal solution? If you don't know where to get started especially when solving problems in general refer to this [coding interview techniques section](/coding-interview-techniques/).
|
||||
|
||||
- Start with a whiteboard or pen and paper. Show your thought process.
|
||||
- In most companies, if you were to show your thought process while doing, interviewers tend to favour candidates who do this. If you are not confident, start thinking that you are explaining and teaching a 12 year old child about how to solve this question.
|
||||
- Code it out and write your own test cases. Get used to the HackerRank or LeetCode IDEs.
|
||||
- Now with virtual interviews, some companies tend to use HackerRank live to conduct whiteboard interviews. Prepare a pen and paper beside you as you work along. Prepare to remote desktop protocol (RDP) into your computer to show step-by-step workings.
|
||||
- Do not blurt out the solution straightaway as interviewers can tell that you memorize.
|
||||
|
||||
4. Last but not least for algorithms heavy interviews, you might really want to save your time looking at [Grind 75](https://techinterviewhandbook.org/grind75). It's a useful curated source of questions to note how much you can prepare for your interview.
|
||||
|
||||
5. Always be prepared for even system design questions! You will never know what comes your way and this is where your projects come in and how much of good practices you apply in them and what do you learn. The [System Design Primer](https://github.com/donnemartin/system-design-primer) is a good start.
|
||||
|
||||
## Do not neglect behavioral interview questions
|
||||
|
||||
Most candidates at least from what I know, tend to neglect this section. As a result, they pass up good opportunities because of this section.
|
||||
|
||||
I suggest reading Cracking the Coding Interview, which explains this section very well in detail. Here are some preparations that you can do before the interview.
|
||||
|
||||
1. Draw up a table in this format. This is so that you know what to say when a question about your projects come up.
|
||||
|
||||
| | Project 1 | Project 2 |
|
||||
| ------------- | --------- | --------- |
|
||||
| Strength 1 | | |
|
||||
| Strength 2 | | |
|
||||
| Weakness 1 | | |
|
||||
| Weakness 2 | | |
|
||||
| Improvement 1 | | |
|
||||
| Improvement 2 | | |
|
||||
|
||||
2. For those with portfolio websites, do be prepared to answer "What do you think can be done better to improve your website?" I highly suggest inspecting your console and using UI/UX principles to state the improvements. It would be also good for front end engineering roles to state how you can better engineer your website.
|
||||
|
||||
3. When preparing, do not focus your answers heavily on your team. Instead, the interviewers want to see how you have grown as an individual and the difficulties that you encounter. Be also prepared to stand strong on your answers and do not give an "I think" vibes to the interviewer. They will tend to have a bad impression.
|
||||
|
||||
4. Certain companies go by rubrics for this and they do not disclose this! However, always be humble and thank the interviewers for helping even if you are unable to justify.
|
||||
|
||||
## Interview day
|
||||
|
||||
As always, have a goodnight sleep before and adjust your sleep cycle <strong>at least 3 days</strong> prior. If you do not know where to start form, start from a brute force solution and manipulate the data structure to your advantage.
|
||||
|
||||
Most interviewers like optimized solutions but they like how you can design a <strong>simple solution</strong> to the problem!
|
||||
|
||||
## Conclusion
|
||||
|
||||
All the best in your preparations! Hope my shortcuts help for those of you who are extremely busy!
|
||||
10
apps/website/contents/_components/InDocAd.js
Normal file
10
apps/website/contents/_components/InDocAd.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import React from 'react';
|
||||
import SidebarAd from '@site/src/components/SidebarAd';
|
||||
|
||||
export default function InDocAd() {
|
||||
return (
|
||||
<div className="padding-top--lg">
|
||||
<SidebarAd position="in_doc" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
843
apps/website/contents/_components/QuestionGroups.json
Normal file
843
apps/website/contents/_components/QuestionGroups.json
Normal file
@@ -0,0 +1,843 @@
|
||||
{
|
||||
"Week 1": [
|
||||
{
|
||||
"slug": "two-sum",
|
||||
"title": "Two Sum",
|
||||
"url": "https://leetcode.com/problems/two-sum",
|
||||
"duration": 15,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 1,
|
||||
"topic": "array",
|
||||
"routines": ["hashing"]
|
||||
},
|
||||
{
|
||||
"slug": "valid-parentheses",
|
||||
"title": "Valid Parentheses",
|
||||
"url": "https://leetcode.com/problems/valid-parentheses",
|
||||
"duration": 20,
|
||||
"epi": 3,
|
||||
"difficulty": "Easy",
|
||||
"id": 20,
|
||||
"topic": "stack",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "merge-two-sorted-lists",
|
||||
"title": "Merge Two Sorted Lists",
|
||||
"url": "https://leetcode.com/problems/merge-two-sorted-lists",
|
||||
"duration": 20,
|
||||
"epi": 0,
|
||||
"difficulty": "Easy",
|
||||
"id": 21,
|
||||
"topic": "linked-list",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "best-time-to-buy-and-sell-stock",
|
||||
"title": "Best Time to Buy and Sell Stock",
|
||||
"url": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock",
|
||||
"duration": 20,
|
||||
"epi": 0,
|
||||
"difficulty": "Easy",
|
||||
"id": 121,
|
||||
"topic": "array",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "valid-palindrome",
|
||||
"title": "Valid Palindrome",
|
||||
"url": "https://leetcode.com/problems/valid-palindrome",
|
||||
"duration": 15,
|
||||
"epi": 2,
|
||||
"difficulty": "Easy",
|
||||
"id": 125,
|
||||
"topic": "string",
|
||||
"routines": ["palindrome"]
|
||||
},
|
||||
{
|
||||
"slug": "invert-binary-tree",
|
||||
"title": "Invert Binary Tree",
|
||||
"url": "https://leetcode.com/problems/invert-binary-tree",
|
||||
"duration": 15,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 226,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "valid-anagram",
|
||||
"title": "Valid Anagram",
|
||||
"url": "https://leetcode.com/problems/valid-anagram",
|
||||
"duration": 15,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 242,
|
||||
"topic": "string",
|
||||
"routines": ["anagram"]
|
||||
},
|
||||
{
|
||||
"slug": "binary-search",
|
||||
"title": "Binary Search",
|
||||
"url": "https://leetcode.com/problems/binary-search",
|
||||
"duration": 15,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 792,
|
||||
"topic": "binary-search",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "flood-fill",
|
||||
"title": "Flood Fill",
|
||||
"url": "https://leetcode.com/problems/flood-fill",
|
||||
"duration": 20,
|
||||
"epi": 2,
|
||||
"difficulty": "Easy",
|
||||
"id": 733,
|
||||
"topic": "graph",
|
||||
"routines": ["matrix", "depth-first-search"]
|
||||
},
|
||||
{
|
||||
"slug": "lowest-common-ancestor-of-a-binary-search-tree",
|
||||
"title": "Lowest Common Ancestor of a Binary Search Tree",
|
||||
"url": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree",
|
||||
"duration": 20,
|
||||
"epi": 1,
|
||||
"difficulty": "Easy",
|
||||
"id": 235,
|
||||
"topic": "binary-search-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "balanced-binary-tree",
|
||||
"title": "Balanced Binary Tree",
|
||||
"url": "https://leetcode.com/problems/balanced-binary-tree",
|
||||
"duration": 15,
|
||||
"epi": 0,
|
||||
"difficulty": "Easy",
|
||||
"id": 110,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "linked-list-cycle",
|
||||
"title": "Linked List Cycle",
|
||||
"url": "https://leetcode.com/problems/linked-list-cycle",
|
||||
"duration": 20,
|
||||
"epi": 1,
|
||||
"difficulty": "Easy",
|
||||
"id": 141,
|
||||
"topic": "linked-list",
|
||||
"routines": ["two-pointers"]
|
||||
}
|
||||
],
|
||||
"Week 2": [
|
||||
{
|
||||
"slug": "implement-queue-using-stacks",
|
||||
"title": "Implement Queue using Stacks",
|
||||
"url": "https://leetcode.com/problems/implement-queue-using-stacks",
|
||||
"duration": 20,
|
||||
"epi": 3,
|
||||
"difficulty": "Easy",
|
||||
"id": 232,
|
||||
"topic": "stack",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "first-bad-version",
|
||||
"title": "First Bad Version",
|
||||
"url": "https://leetcode.com/problems/first-bad-version",
|
||||
"duration": 20,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 278,
|
||||
"topic": "binary-search",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "ransom-note",
|
||||
"title": "Ransom Note",
|
||||
"url": "https://leetcode.com/problems/ransom-note",
|
||||
"duration": 15,
|
||||
"epi": 0,
|
||||
"difficulty": "Easy",
|
||||
"id": 383,
|
||||
"topic": "hash-table",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "climbing-stairs",
|
||||
"title": "Climbing Stairs",
|
||||
"url": "https://leetcode.com/problems/climbing-stairs",
|
||||
"duration": 20,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 70,
|
||||
"topic": "dynamic-programming",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "longest-palindrome",
|
||||
"title": "Longest Palindrome",
|
||||
"url": "https://leetcode.com/problems/longest-palindrome",
|
||||
"duration": 20,
|
||||
"epi": 2,
|
||||
"difficulty": "Easy",
|
||||
"id": 409,
|
||||
"topic": "string",
|
||||
"routines": ["palindrome"]
|
||||
},
|
||||
{
|
||||
"slug": "reverse-linked-list",
|
||||
"title": "Reverse Linked List",
|
||||
"url": "https://leetcode.com/problems/reverse-linked-list",
|
||||
"duration": 20,
|
||||
"epi": 1,
|
||||
"difficulty": "Easy",
|
||||
"id": 206,
|
||||
"topic": "linked-list",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "majority-element",
|
||||
"title": "Majority Element",
|
||||
"url": "https://leetcode.com/problems/majority-element",
|
||||
"duration": 20,
|
||||
"epi": 2,
|
||||
"difficulty": "Easy",
|
||||
"id": 169,
|
||||
"topic": "array",
|
||||
"routines": ["sorting"]
|
||||
},
|
||||
{
|
||||
"slug": "add-binary",
|
||||
"title": "Add Binary",
|
||||
"url": "https://leetcode.com/problems/add-binary",
|
||||
"duration": 15,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 67,
|
||||
"topic": "binary",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "diameter-of-binary-tree",
|
||||
"title": "Diameter of Binary Tree",
|
||||
"url": "https://leetcode.com/problems/diameter-of-binary-tree",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 543,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "middle-of-the-linked-list",
|
||||
"title": "Middle of the Linked List",
|
||||
"url": "https://leetcode.com/problems/middle-of-the-linked-list",
|
||||
"duration": 20,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 908,
|
||||
"topic": "linked-list",
|
||||
"routines": ["two-pointers"]
|
||||
},
|
||||
{
|
||||
"slug": "maximum-depth-of-binary-tree",
|
||||
"title": "Maximum Depth of Binary Tree",
|
||||
"url": "https://leetcode.com/problems/maximum-depth-of-binary-tree",
|
||||
"duration": 15,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 104,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "contains-duplicate",
|
||||
"title": "Contains Duplicate",
|
||||
"url": "https://leetcode.com/problems/contains-duplicate",
|
||||
"duration": 15,
|
||||
"epi": null,
|
||||
"difficulty": "Easy",
|
||||
"id": 217,
|
||||
"topic": "array",
|
||||
"routines": ["hash-table", "sorting"]
|
||||
}
|
||||
],
|
||||
"Week 3": [
|
||||
{
|
||||
"slug": "min-stack",
|
||||
"title": "Min Stack",
|
||||
"url": "https://leetcode.com/problems/min-stack",
|
||||
"duration": 20,
|
||||
"epi": 0,
|
||||
"difficulty": "Medium",
|
||||
"id": 155,
|
||||
"topic": "stack",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "maximum-subarray",
|
||||
"title": "Maximum Subarray",
|
||||
"url": "https://leetcode.com/problems/maximum-subarray",
|
||||
"duration": 20,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 53,
|
||||
"topic": "dynamic-programming",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "insert-interval",
|
||||
"title": "Insert Interval",
|
||||
"url": "https://leetcode.com/problems/insert-interval",
|
||||
"duration": 25,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 57,
|
||||
"topic": "array",
|
||||
"routines": ["interval"]
|
||||
},
|
||||
{
|
||||
"slug": "01-matrix",
|
||||
"title": "01 Matrix",
|
||||
"url": "https://leetcode.com/problems/01-matrix",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 542,
|
||||
"topic": "graph",
|
||||
"routines": ["breadth-first-search"]
|
||||
},
|
||||
{
|
||||
"slug": "k-closest-points-to-origin",
|
||||
"title": "K Closest Points to Origin",
|
||||
"url": "https://leetcode.com/problems/k-closest-points-to-origin",
|
||||
"duration": 30,
|
||||
"epi": 1,
|
||||
"difficulty": "Medium",
|
||||
"id": 1014,
|
||||
"topic": "heap",
|
||||
"routines": ["geometry"]
|
||||
},
|
||||
{
|
||||
"slug": "longest-substring-without-repeating-characters",
|
||||
"title": "Longest Substring Without Repeating Characters",
|
||||
"url": "https://leetcode.com/problems/longest-substring-without-repeating-characters",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 3,
|
||||
"topic": "string",
|
||||
"routines": ["sliding-window"]
|
||||
},
|
||||
{
|
||||
"slug": "3sum",
|
||||
"title": "3Sum",
|
||||
"url": "https://leetcode.com/problems/3sum",
|
||||
"duration": 30,
|
||||
"epi": 0,
|
||||
"difficulty": "Medium",
|
||||
"id": 15,
|
||||
"topic": "array",
|
||||
"routines": ["two-pointers"]
|
||||
},
|
||||
{
|
||||
"slug": "binary-tree-level-order-traversal",
|
||||
"title": "Binary Tree Level Order Traversal",
|
||||
"url": "https://leetcode.com/problems/binary-tree-level-order-traversal",
|
||||
"duration": 20,
|
||||
"epi": 1,
|
||||
"difficulty": "Medium",
|
||||
"id": 102,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "clone-graph",
|
||||
"title": "Clone Graph",
|
||||
"url": "https://leetcode.com/problems/clone-graph",
|
||||
"duration": 25,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 133,
|
||||
"topic": "graph",
|
||||
"routines": ["depth-first-search", "breadth-first-search"]
|
||||
},
|
||||
{
|
||||
"slug": "evaluate-reverse-polish-notation",
|
||||
"title": "Evaluate Reverse Polish Notation",
|
||||
"url": "https://leetcode.com/problems/evaluate-reverse-polish-notation",
|
||||
"duration": 30,
|
||||
"epi": 2,
|
||||
"difficulty": "Medium",
|
||||
"id": 150,
|
||||
"topic": "stack",
|
||||
"routines": []
|
||||
}
|
||||
],
|
||||
"Week 4": [
|
||||
{
|
||||
"slug": "course-schedule",
|
||||
"title": "Course Schedule",
|
||||
"url": "https://leetcode.com/problems/course-schedule",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 207,
|
||||
"topic": "graph",
|
||||
"routines": ["topo-sort"]
|
||||
},
|
||||
{
|
||||
"slug": "implement-trie-prefix-tree",
|
||||
"title": "Implement Trie (Prefix Tree)",
|
||||
"url": "https://leetcode.com/problems/implement-trie-prefix-tree",
|
||||
"duration": 35,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 208,
|
||||
"topic": "trie",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "coin-change",
|
||||
"title": "Coin Change",
|
||||
"url": "https://leetcode.com/problems/coin-change",
|
||||
"duration": 25,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 322,
|
||||
"topic": "dynamic-programming",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "product-of-array-except-self",
|
||||
"title": "Product of Array Except Self",
|
||||
"url": "https://leetcode.com/problems/product-of-array-except-self",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 238,
|
||||
"topic": "array",
|
||||
"routines": ["prefix-sum"]
|
||||
},
|
||||
{
|
||||
"slug": "validate-binary-search-tree",
|
||||
"title": "Validate Binary Search Tree",
|
||||
"url": "https://leetcode.com/problems/validate-binary-search-tree",
|
||||
"duration": 20,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 98,
|
||||
"topic": "binary-search-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "number-of-islands",
|
||||
"title": "Number of Islands",
|
||||
"url": "https://leetcode.com/problems/number-of-islands",
|
||||
"duration": 25,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 200,
|
||||
"topic": "graph",
|
||||
"routines": ["depth-first-search", " breadth-first-search"]
|
||||
},
|
||||
{
|
||||
"slug": "rotting-oranges",
|
||||
"title": "Rotting Oranges",
|
||||
"url": "https://leetcode.com/problems/rotting-oranges",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 1036,
|
||||
"topic": "graph",
|
||||
"routines": ["breadth-first-search"]
|
||||
},
|
||||
{
|
||||
"slug": "search-in-rotated-sorted-array",
|
||||
"title": "Search in Rotated Sorted Array",
|
||||
"url": "https://leetcode.com/problems/search-in-rotated-sorted-array",
|
||||
"duration": 30,
|
||||
"epi": 2,
|
||||
"difficulty": "Medium",
|
||||
"id": 33,
|
||||
"topic": "binary-search",
|
||||
"routines": []
|
||||
}
|
||||
],
|
||||
"Week 5": [
|
||||
{
|
||||
"slug": "combination-sum",
|
||||
"title": "Combination Sum",
|
||||
"url": "https://leetcode.com/problems/combination-sum",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 39,
|
||||
"topic": "array",
|
||||
"routines": ["backtracking"]
|
||||
},
|
||||
{
|
||||
"slug": "permutations",
|
||||
"title": "Permutations",
|
||||
"url": "https://leetcode.com/problems/permutations",
|
||||
"duration": 30,
|
||||
"epi": 2,
|
||||
"difficulty": "Medium",
|
||||
"id": 46,
|
||||
"topic": "recursion",
|
||||
"routines": ["backtracking"]
|
||||
},
|
||||
{
|
||||
"slug": "merge-intervals",
|
||||
"title": "Merge Intervals",
|
||||
"url": "https://leetcode.com/problems/merge-intervals",
|
||||
"duration": 30,
|
||||
"epi": 3,
|
||||
"difficulty": "Medium",
|
||||
"id": 56,
|
||||
"topic": "array",
|
||||
"routines": ["interval"]
|
||||
},
|
||||
{
|
||||
"slug": "lowest-common-ancestor-of-a-binary-tree",
|
||||
"title": "Lowest Common Ancestor of a Binary Tree",
|
||||
"url": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree",
|
||||
"duration": 25,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 236,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "time-based-key-value-store",
|
||||
"title": "Time Based Key-Value Store",
|
||||
"url": "https://leetcode.com/problems/time-based-key-value-store",
|
||||
"duration": 35,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 1023,
|
||||
"topic": "binary-search",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "accounts-merge",
|
||||
"title": "Accounts Merge",
|
||||
"url": "https://leetcode.com/problems/accounts-merge",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 721,
|
||||
"topic": "graph",
|
||||
"routines": ["depth-first-search", "union-find"]
|
||||
},
|
||||
{
|
||||
"slug": "sort-colors",
|
||||
"title": "Sort Colors",
|
||||
"url": "https://leetcode.com/problems/sort-colors",
|
||||
"duration": 25,
|
||||
"epi": 0,
|
||||
"difficulty": "Medium",
|
||||
"id": 75,
|
||||
"topic": "array",
|
||||
"routines": ["two-pointers"]
|
||||
},
|
||||
{
|
||||
"slug": "word-break",
|
||||
"title": "Word Break",
|
||||
"url": "https://leetcode.com/problems/word-break",
|
||||
"duration": 30,
|
||||
"epi": 2,
|
||||
"difficulty": "Medium",
|
||||
"id": 139,
|
||||
"topic": "trie",
|
||||
"routines": []
|
||||
}
|
||||
],
|
||||
"Week 6": [
|
||||
{
|
||||
"slug": "partition-equal-subset-sum",
|
||||
"title": "Partition Equal Subset Sum",
|
||||
"url": "https://leetcode.com/problems/partition-equal-subset-sum",
|
||||
"duration": 30,
|
||||
"epi": 2,
|
||||
"difficulty": "Medium",
|
||||
"id": 416,
|
||||
"topic": "dynamic-programming",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "string-to-integer-atoi",
|
||||
"title": "String to Integer (atoi)",
|
||||
"url": "https://leetcode.com/problems/string-to-integer-atoi",
|
||||
"duration": 25,
|
||||
"epi": 0,
|
||||
"difficulty": "Medium",
|
||||
"id": 8,
|
||||
"topic": "string",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "spiral-matrix",
|
||||
"title": "Spiral Matrix",
|
||||
"url": "https://leetcode.com/problems/spiral-matrix",
|
||||
"duration": 25,
|
||||
"epi": 1,
|
||||
"difficulty": "Medium",
|
||||
"id": 54,
|
||||
"topic": "matrix",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "subsets",
|
||||
"title": "Subsets",
|
||||
"url": "https://leetcode.com/problems/subsets",
|
||||
"duration": 30,
|
||||
"epi": 3,
|
||||
"difficulty": "Medium",
|
||||
"id": 78,
|
||||
"topic": "recursion",
|
||||
"routines": ["backtracking"]
|
||||
},
|
||||
{
|
||||
"slug": "binary-tree-right-side-view",
|
||||
"title": "Binary Tree Right Side View",
|
||||
"url": "https://leetcode.com/problems/binary-tree-right-side-view",
|
||||
"duration": 20,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 199,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "longest-palindromic-substring",
|
||||
"title": "Longest Palindromic Substring",
|
||||
"url": "https://leetcode.com/problems/longest-palindromic-substring",
|
||||
"duration": 25,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 5,
|
||||
"topic": "string",
|
||||
"routines": ["palindrome", "two-pointer", "dynamic-programming"]
|
||||
},
|
||||
{
|
||||
"slug": "unique-paths",
|
||||
"title": "Unique Paths",
|
||||
"url": "https://leetcode.com/problems/unique-paths",
|
||||
"duration": 20,
|
||||
"epi": 2,
|
||||
"difficulty": "Medium",
|
||||
"id": 62,
|
||||
"topic": "dynamic-programming",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "construct-binary-tree-from-preorder-and-inorder-traversal",
|
||||
"title": "Construct Binary Tree from Preorder and Inorder Traversal",
|
||||
"url": "https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal",
|
||||
"duration": 25,
|
||||
"epi": 2,
|
||||
"difficulty": "Medium",
|
||||
"id": 105,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "container-with-most-water",
|
||||
"title": "Container With Most Water",
|
||||
"url": "https://leetcode.com/problems/container-with-most-water",
|
||||
"duration": 35,
|
||||
"epi": 2,
|
||||
"difficulty": "Medium",
|
||||
"id": 11,
|
||||
"topic": "array",
|
||||
"routines": ["greedy", "two-pointers"]
|
||||
}
|
||||
],
|
||||
"Week 7": [
|
||||
{
|
||||
"slug": "letter-combinations-of-a-phone-number",
|
||||
"title": "Letter Combinations of a Phone Number",
|
||||
"url": "https://leetcode.com/problems/letter-combinations-of-a-phone-number",
|
||||
"duration": 30,
|
||||
"epi": 3,
|
||||
"difficulty": "Medium",
|
||||
"id": 17,
|
||||
"topic": "recursion",
|
||||
"routines": ["backtracking"]
|
||||
},
|
||||
{
|
||||
"slug": "word-search",
|
||||
"title": "Word Search",
|
||||
"url": "https://leetcode.com/problems/word-search",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 79,
|
||||
"topic": "graph",
|
||||
"routines": ["backtracking"]
|
||||
},
|
||||
{
|
||||
"slug": "find-all-anagrams-in-a-string",
|
||||
"title": "Find All Anagrams in a String",
|
||||
"url": "https://leetcode.com/problems/find-all-anagrams-in-a-string",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 438,
|
||||
"topic": "string",
|
||||
"routines": ["anagram"]
|
||||
},
|
||||
{
|
||||
"slug": "minimum-height-trees",
|
||||
"title": "Minimum Height Trees",
|
||||
"url": "https://leetcode.com/problems/minimum-height-trees",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 310,
|
||||
"topic": "graph",
|
||||
"routines": ["topo-sort"]
|
||||
},
|
||||
{
|
||||
"slug": "task-scheduler",
|
||||
"title": "Task Scheduler",
|
||||
"url": "https://leetcode.com/problems/task-scheduler",
|
||||
"duration": 35,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 621,
|
||||
"topic": "heap",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "lru-cache",
|
||||
"title": "LRU Cache",
|
||||
"url": "https://leetcode.com/problems/lru-cache",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 146,
|
||||
"topic": "linked-list",
|
||||
"routines": ["hash-table"]
|
||||
},
|
||||
{
|
||||
"slug": "kth-smallest-element-in-a-bst",
|
||||
"title": "Kth Smallest Element in a BST",
|
||||
"url": "https://leetcode.com/problems/kth-smallest-element-in-a-bst",
|
||||
"duration": 25,
|
||||
"epi": null,
|
||||
"difficulty": "Medium",
|
||||
"id": 230,
|
||||
"topic": "binary-search-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "minimum-window-substring",
|
||||
"title": "Minimum Window Substring",
|
||||
"url": "https://leetcode.com/problems/minimum-window-substring",
|
||||
"duration": 30,
|
||||
"epi": 3,
|
||||
"difficulty": "Hard",
|
||||
"id": 76,
|
||||
"topic": "string",
|
||||
"routines": ["sliding-window"]
|
||||
}
|
||||
],
|
||||
"Week 8": [
|
||||
{
|
||||
"slug": "serialize-and-deserialize-binary-tree",
|
||||
"title": "Serialize and Deserialize Binary Tree",
|
||||
"url": "https://leetcode.com/problems/serialize-and-deserialize-binary-tree",
|
||||
"duration": 40,
|
||||
"epi": null,
|
||||
"difficulty": "Hard",
|
||||
"id": 297,
|
||||
"topic": "binary-tree",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "trapping-rain-water",
|
||||
"title": "Trapping Rain Water",
|
||||
"url": "https://leetcode.com/problems/trapping-rain-water",
|
||||
"duration": 35,
|
||||
"epi": null,
|
||||
"difficulty": "Hard",
|
||||
"id": 42,
|
||||
"topic": "stack",
|
||||
"routines": ["monotonic-stack"]
|
||||
},
|
||||
{
|
||||
"slug": "find-median-from-data-stream",
|
||||
"title": "Find Median from Data Stream",
|
||||
"url": "https://leetcode.com/problems/find-median-from-data-stream",
|
||||
"duration": 30,
|
||||
"epi": 3,
|
||||
"difficulty": "Hard",
|
||||
"id": 295,
|
||||
"topic": "heap",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "word-ladder",
|
||||
"title": "Word Ladder",
|
||||
"url": "https://leetcode.com/problems/word-ladder",
|
||||
"duration": 45,
|
||||
"epi": null,
|
||||
"difficulty": "Hard",
|
||||
"id": 127,
|
||||
"topic": "graph",
|
||||
"routines": ["breadth-first-search"]
|
||||
},
|
||||
{
|
||||
"slug": "basic-calculator",
|
||||
"title": "Basic Calculator",
|
||||
"url": "https://leetcode.com/problems/basic-calculator",
|
||||
"duration": 40,
|
||||
"epi": null,
|
||||
"difficulty": "Hard",
|
||||
"id": 224,
|
||||
"topic": "stack",
|
||||
"routines": ["parsing"]
|
||||
},
|
||||
{
|
||||
"slug": "maximum-profit-in-job-scheduling",
|
||||
"title": "Maximum Profit in Job Scheduling",
|
||||
"url": "https://leetcode.com/problems/maximum-profit-in-job-scheduling",
|
||||
"duration": 45,
|
||||
"epi": null,
|
||||
"difficulty": "Hard",
|
||||
"id": 1352,
|
||||
"topic": "binary-search",
|
||||
"routines": ["dynamic-programming"]
|
||||
},
|
||||
{
|
||||
"slug": "merge-k-sorted-lists",
|
||||
"title": "Merge k Sorted Lists",
|
||||
"url": "https://leetcode.com/problems/merge-k-sorted-lists",
|
||||
"duration": 30,
|
||||
"epi": null,
|
||||
"difficulty": "Hard",
|
||||
"id": 23,
|
||||
"topic": "heap",
|
||||
"routines": []
|
||||
},
|
||||
{
|
||||
"slug": "largest-rectangle-in-histogram",
|
||||
"title": "Largest Rectangle in Histogram",
|
||||
"url": "https://leetcode.com/problems/largest-rectangle-in-histogram",
|
||||
"duration": 35,
|
||||
"epi": 3,
|
||||
"difficulty": "Hard",
|
||||
"id": 84,
|
||||
"topic": "stack",
|
||||
"routines": ["monotonic-stack"]
|
||||
}
|
||||
]
|
||||
}
|
||||
60
apps/website/contents/_components/QuestionList.js
Normal file
60
apps/website/contents/_components/QuestionList.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import React from 'react';
|
||||
|
||||
import QuestionGroups from './QuestionGroups.json';
|
||||
|
||||
function DifficultyLabel({ difficulty }) {
|
||||
return (
|
||||
<span
|
||||
style={{
|
||||
fontWeight: 600,
|
||||
color: {
|
||||
Easy: 'rgb(0, 184, 163)',
|
||||
Medium: 'rgb(255, 192, 30)',
|
||||
Hard: 'rgb(255, 55, 95)',
|
||||
}[difficulty],
|
||||
}}>
|
||||
{difficulty}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
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>
|
||||
<DifficultyLabel difficulty={question.difficulty} />
|
||||
</td>
|
||||
<td>{question.duration} mins</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
11
apps/website/contents/_courses/AlgorithmCourses.md
Normal file
11
apps/website/contents/_courses/AlgorithmCourses.md
Normal file
@@ -0,0 +1,11 @@
|
||||
### [AlgoMonster](https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=)
|
||||
|
||||
AlgoMonster aims to help you ace the technical interview **in the shortest time possible**. By Google engineers, AlgoMonster uses a data-driven approach to teach you the most useful key question patterns and has contents to help you quickly revise basic data structures and algorithms. Best of all, AlgoMonster is not subscription-based - pay a one-time fee and get **lifetime access**. [**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://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
|
||||
This course on by Design Gurus 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!** [**Get lifetime access now →**](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
|
||||
### [Master the Coding Interview: Data Structures + Algorithms](https://fxo.co/DQpY)
|
||||
|
||||
This Udemy bestseller is one of the highest-rated interview preparation course (4.6 stars, 21.5k ratings, 135k students) and packs **19 hours** worth of contents into it. Like Tech Interview Handbook, it goes beyond coding interviews and covers resume, non-technical interviews, negotiations. It's an all-in-one package! Note that JavaScript is being used for the coding demos. [**Check it out →**](https://fxo.co/DQpY)
|
||||
72
apps/website/contents/algorithms/__template__.md
Normal file
72
apps/website/contents/algorithms/__template__.md
Normal file
@@ -0,0 +1,72 @@
|
||||
- [ ] introduction.md
|
||||
- [x] array.md
|
||||
- [x] string.md
|
||||
- [x] sorting-searching.md
|
||||
- [x] recursion.md
|
||||
- [x] hash-table.md
|
||||
- [x] linked-list.md
|
||||
- [x] stack.md
|
||||
- [x] queue.md
|
||||
- [x] matrix.md
|
||||
- [x] graph.md
|
||||
- [x] interval.md
|
||||
- [x] tree.md
|
||||
- [x] heap.md
|
||||
- [x] trie.md
|
||||
- [x] geometry.md
|
||||
- [x] math.md
|
||||
- [x] dynamic-programming.md
|
||||
- [x] binary.md
|
||||
<!-- - [ ] oop.md -->
|
||||
|
||||
## Introduction
|
||||
|
||||
TODO
|
||||
|
||||
## Learning resources
|
||||
|
||||
TODO
|
||||
|
||||
## Implementations
|
||||
|
||||
| Language | API |
|
||||
| ---------- | ---- |
|
||||
| C++ | []() |
|
||||
| Java | []() |
|
||||
| Python | []() |
|
||||
| JavaScript | []() |
|
||||
|
||||
## Time complexity
|
||||
|
||||
TODO
|
||||
|
||||
| Operation | Big-O | Note |
|
||||
| --------- | ----- | ---- |
|
||||
| Access | O(n) | |
|
||||
| Search | O(n) | |
|
||||
| Insert | O(1) | |
|
||||
| Remove | O(1) | |
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
TODO
|
||||
|
||||
## Corner cases
|
||||
|
||||
TODO
|
||||
|
||||
## Techniques
|
||||
|
||||
TODO
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
TODO
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
TODO
|
||||
139
apps/website/contents/algorithms/array.md
Normal file
139
apps/website/contents/algorithms/array.md
Normal file
@@ -0,0 +1,139 @@
|
||||
---
|
||||
id: array
|
||||
title: Array cheatsheet for coding interviews
|
||||
description: Array study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
array coding interview study guide,
|
||||
array tips for coding interviews,
|
||||
array practice questions,
|
||||
array useful techniques,
|
||||
array time complexity,
|
||||
array recommended study resources,
|
||||
]
|
||||
sidebar_label: Array
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-array.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Arrays hold values of the same type at contiguous memory locations. In an array, we're usually concerned about two things - the position/index of an element and the element itself. Different programming languages implement arrays under the hood differently and can affect the time complexity of operations you make to the array. In some languages like Python, JavaScript, Ruby, PHP, the array (or list in Python) size is dynamic and you do not need to have a size defined beforehand when creating the array. As a result, people usually have an easier time using these languages for interviews.
|
||||
|
||||
Arrays are among the most common data structures encountered during interviews. Questions which ask about other topics would likely involve arrays/sequences as well. Mastery of array is essential for interviews!
|
||||
|
||||
**Advantages**
|
||||
|
||||
- Store multiple elements of the same type with one single variable name
|
||||
- Accessing elements is fast as long as you have the index, as opposed to [linked lists](./linked-list.md) where you have to traverse from the head.
|
||||
|
||||
**Disadvantages**
|
||||
|
||||
- Addition and removal of elements into/from the middle of an array is slow because the remaining elements need to be shifted to accommodate the new/missing element. An exception to this is if the position to be inserted/removed is at the end of the array.
|
||||
- For certain languages where the array size is fixed, it cannot alter its size after initialization. If an insertion causes the total number of elements to exceed the size, a new array has to be allocated and the existing elements have to be copied over. The act of creating a new array and transferring elements over takes O(n) time.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [Array in Data Structure: What is, Arrays Operations](https://www.guru99.com/array-data-structure.html), Guru99
|
||||
- Videos
|
||||
- [Arrays](https://www.coursera.org/lecture/data-structures/arrays-OsBSF), University of California San Diego
|
||||
|
||||
## Common terms
|
||||
|
||||
Common terms you see when doing problems involving arrays:
|
||||
|
||||
- Subarray - A range of contiguous values within an array.
|
||||
- Example: given an array `[2, 3, 6, 1, 5, 4]`, `[3, 6, 1]` is a subarray while `[3, 1, 5]` is not a subarray.
|
||||
- Subsequence - A sequence that can be derived from the given sequence by deleting some or no elements without changing the order of the remaining elements.
|
||||
- Example: given an array `[2, 3, 6, 1, 5, 4]`, `[3, 1, 5]` is a subsequence but `[3, 5, 1]` is not a subsequence.
|
||||
|
||||
## Time complexity
|
||||
|
||||
| Operation | Big-O | Note |
|
||||
| --- | --- | --- |
|
||||
| Access | O(1) | |
|
||||
| Search | O(n) | |
|
||||
| Search (sorted array) | O(log(n)) | |
|
||||
| Insert | O(n) | Insertion would require shifting all the subsequent elements to the right by one and that takes O(n) |
|
||||
| Insert (at the end) | O(1) | Special case of insertion where no other element needs to be shifted |
|
||||
| Remove | O(n) | Removal would require shifting all the subsequent elements to the left by one and that takes O(n) |
|
||||
| Remove (at the end) | O(1) | Special case of removal where no other element needs to be shifted |
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
- Clarify if there are duplicate values in the array. Would the presence of duplicate values affect the answer? Does it make the question simpler or harder?
|
||||
- When using an index to iterate through array elements, be careful not to go out of bounds.
|
||||
- Be mindful about slicing or concatenating arrays in your code. Typically, slicing and concatenating arrays would take O(n) time. Use start and end indices to demarcate a subarray/range where possible.
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty sequence
|
||||
- Sequence with 1 or 2 elements
|
||||
- Sequence with repeated elements
|
||||
- Duplicated values in the sequence
|
||||
|
||||
## Techniques
|
||||
|
||||
Note that because both arrays and strings are sequences (a string is an array of characters), most of the techniques here will apply to string problems.
|
||||
|
||||
### Sliding window
|
||||
|
||||
Master the [sliding window technique](https://discuss.leetcode.com/topic/30941/here-is-a-10-line-template-that-can-solve-most-substring-problems) that applies to many subarray/substring problems. In a sliding window, the two pointers usually move in the same direction will never overtake each other. This ensures that each value is only visited at most twice and the time complexity is still O(n). Examples: [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/), [Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum/), [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/)
|
||||
|
||||
### Two pointers
|
||||
|
||||
Two pointers is a more general version of sliding window where the pointers can cross each other and can be on different arrays. Examples: [Sort Colors](https://leetcode.com/problems/sort-colors/), [Palindromic Substrings](https://leetcode.com/problems/palindromic-substrings/)
|
||||
|
||||
When you are given two arrays to process, it is common to have one index per array (pointer) to traverse/compare the both of them, incrementing one of the pointers when relevant. For example, we use this approach to merge two sorted arrays. Examples: [Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/)
|
||||
|
||||
### Traversing from the right
|
||||
|
||||
Sometimes you can traverse the array starting from the right instead of the conventional approach of from the left. Examples: [Daily Temperatures](https://leetcode.com/problems/daily-temperatures/), [Number of Visible People in a Queue](https://leetcode.com/problems/number-of-visible-people-in-a-queue/)
|
||||
|
||||
### Sorting the array
|
||||
|
||||
Is the array sorted or partially sorted? If it is, some form of binary search should be possible. This also usually means that the interviewer is looking for a solution that is faster than O(n).
|
||||
|
||||
Can you sort the array? Sometimes sorting the array first may significantly simplify the problem. Obviously this would not work if the order of array elements need to be preserved. Examples: [Merge Intervals](https://leetcode.com/problems/merge-intervals/), [Non-overlapping Intervals](https://leetcode.com/problems/non-overlapping-intervals/)
|
||||
|
||||
### Precomputation
|
||||
|
||||
For questions where summation or multiplication of a subarray is involved, pre-computation using hashing or a prefix/suffix sum/product might be useful. Examples: [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/), [Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum/), [LeetCode questions tagged "prefix-sum"](https://leetcode.com/tag/prefix-sum/)
|
||||
|
||||
### Index as a hash key
|
||||
|
||||
If you are given a sequence and the interviewer asks for O(1) space, it might be possible to use the array itself as a hash table. For example, if the array only has values from 1 to N, where N is the length of the array, negate the value at that index (minus one) to indicate presence of that number. Examples: [First Missing Positive](https://leetcode.com/problems/first-missing-positive/), [Daily Temperatures](https://leetcode.com/problems/daily-temperatures/)
|
||||
|
||||
### Traversing the array more than once
|
||||
|
||||
This might be obvious, but traversing the array twice/thrice (as long as fewer than n times) is still O(n). Sometimes traversing the array more than once can help you solve the problem while keeping the time complexity to O(n).
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Two Sum](https://leetcode.com/problems/two-sum/)
|
||||
- [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)
|
||||
- [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/)
|
||||
- [Maximum Subarray](https://leetcode.com/problems/maximum-subarray/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Contains Duplicate](https://leetcode.com/problems/contains-duplicate/)
|
||||
- [Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray/)
|
||||
- [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)
|
||||
- [3Sum](https://leetcode.com/problems/3sum/)
|
||||
- [Container With Most Water](https://leetcode.com/problems/container-with-most-water/)
|
||||
- [Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
78
apps/website/contents/algorithms/binary.md
Normal file
78
apps/website/contents/algorithms/binary.md
Normal file
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: binary
|
||||
title: Binary cheatsheet for coding interviews
|
||||
description: binary study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
binary coding interview study guide,
|
||||
binary tips for coding interviews,
|
||||
binary practice questions,
|
||||
binary useful techniques,
|
||||
binary time complexity,
|
||||
binary recommended study resources,
|
||||
]
|
||||
sidebar_label: Binary
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-binary.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Knowledge of binary number system and bit manipulation is less important in coding interviews as most Software Engineers do not have to deal with bits, which is more commonly used when dealing with lower level systems and programming languages. They are still asked sometimes, so you should at least still know how to convert a number from decimal form into binary form, and vice versa, in your chosen programming language.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [Bits, Bytes, Building With Binary](https://medium.com/basecs/bits-bytes-building-with-binary-13cb4289aafa), basecs
|
||||
- [Bitwise operation](https://en.wikipedia.org/wiki/Bitwise_operation), Wikipedia
|
||||
- Videos
|
||||
- [Algorithms: Bit Manipulation](https://www.youtube.com/watch?v=NLKQEOgBAnw), HackerRank
|
||||
- Practice
|
||||
- [Practice with bit operations](https://pconrad.github.io/old_pconrad_cs16/topics/bitOps/)
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Be aware and check for overflow/underflow
|
||||
- Negative numbers
|
||||
|
||||
## Techniques
|
||||
|
||||
Questions involving binary representations and bitwise operations are asked sometimes and you must be absolutely familiar with how to convert a number from decimal form into binary form (and vice versa) in your chosen programming language.
|
||||
|
||||
Some helpful utility snippets:
|
||||
|
||||
| Technique | Code |
|
||||
| --- | --- |
|
||||
| Test k<sup>th</sup> bit is set | `num & (1 << k) != 0`. |
|
||||
| Set k<sup>th</sup> bit | <code>num |= (1 << k)</code> |
|
||||
| Turn off k<sup>th</sup> bit | `num &= ~(1 << k)`. |
|
||||
| Toggle the k<sup>th</sup> bit | `num ^= (1 << k)`. |
|
||||
| Multiply by 2<sup>k</sup> | `num << k` |
|
||||
| Divide by 2<sup>k</sup> | `num >> k` |
|
||||
| Check if a number is a power of 2 | `(num & num - 1) == 0` or `(num & (-num)) == num` |
|
||||
| Swapping two variables | `num1 ^= num2; num2 ^= num1; num1 ^= num2` |
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers/)
|
||||
- [Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Counting Bits](https://leetcode.com/problems/counting-bits/)
|
||||
- [Missing Number](https://leetcode.com/problems/missing-number/)
|
||||
- [Reverse Bits](https://leetcode.com/problems/reverse-bits/)
|
||||
- [Single Number](https://leetcode.com/problems/single-number/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
67
apps/website/contents/algorithms/dynamic-programming.md
Normal file
67
apps/website/contents/algorithms/dynamic-programming.md
Normal file
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: dynamic-programming
|
||||
title: Dynamic programming cheatsheet for coding interviews
|
||||
description: Dynamic programming study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
dynamic programming coding interview study guide,
|
||||
dynamic programming tips for coding interviews,
|
||||
dynamic programming practice questions,
|
||||
dynamic programming useful techniques,
|
||||
dynamic programming time complexity,
|
||||
dynamic programming recommended study resources,
|
||||
]
|
||||
sidebar_label: Dynamic programming
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-dynamic-programming.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Dynamic Programming (DP) is usually used to solve optimization problems. The only way to get better at DP is to practice. It takes some amount of practice to be able to recognize that a problem can be solved by DP.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- [Demystifying Dynamic Programming](https://medium.freecodecamp.org/demystifying-dynamic-programming-3efafb8d4296)
|
||||
- [Dynamic Programming – 7 Steps to Solve any DP Interview Problem](https://dev.to/nikolaotasevic/dynamic-programming--7-steps-to-solve-any-dp-interview-problem-3870)
|
||||
- [Less Repetition, More Dynamic Programming](https://medium.com/basecs/less-repetition-more-dynamic-programming-43d29830a630), basecs
|
||||
- [Dynamic Programming](http://www.cs.yale.edu/homes/aspnes/classes/223/notes.html#dynamicProgramming), James Aspnes, Yale University
|
||||
|
||||
## Techniques
|
||||
|
||||
Sometimes you do not need to store the whole DP table in memory, the last two values or the last two rows of the matrix will suffice.
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Climbing Stairs](https://leetcode.com/problems/climbing-stairs/)
|
||||
- [Coin Change](https://leetcode.com/problems/coin-change/)
|
||||
- [House Robber](https://leetcode.com/problems/house-robber/)
|
||||
- [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [0/1 Knapsack or Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum/)
|
||||
- [Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence/)
|
||||
- [Word Break Problem](https://leetcode.com/problems/word-break/)
|
||||
- [Combination Sum](https://leetcode.com/problems/combination-sum-iv/)
|
||||
- [House Robber II](https://leetcode.com/problems/house-robber-ii/)
|
||||
- [Decode Ways](https://leetcode.com/problems/decode-ways/)
|
||||
- [Unique Paths](https://leetcode.com/problems/unique-paths/)
|
||||
- [Jump Game](https://leetcode.com/problems/jump-game/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
### [Grokking Dynamic Programming Patterns for Coding Interviews](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-dynamic-programming)
|
||||
|
||||
Brought to you by the same folks behind the famous ["Grokking the Coding Interview"](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview), this is one of the rare few courses focused on helping you get better at Dynamic Programming questions. If you are interviewing for companies who are famous for asking Dynamic Programming questions (-cough- Google -cough-), this course should be helpful.
|
||||
|
||||
<AlgorithmCourses />
|
||||
79
apps/website/contents/algorithms/geometry.md
Normal file
79
apps/website/contents/algorithms/geometry.md
Normal file
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: geometry
|
||||
title: Geometry cheatsheet for coding interviews
|
||||
description: Geometry study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
geometry coding interview study guide,
|
||||
geometry tips for coding interviews,
|
||||
geometry practice questions,
|
||||
geometry useful techniques,
|
||||
geometry time complexity,
|
||||
geometry recommended study resources,
|
||||
]
|
||||
sidebar_label: Geometry
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-geometry.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Geometry is a branch of mathematics that is concerned with properties of space that are related with distance, shape, size, and relative position of figures. Advanced geometry (e.g. 3D geometry) is not taught in most Computer Science courses, so you can expect that you will only be asked on 2D geometry.
|
||||
|
||||
In algorithm interviews, geometry is usually not be the focus of the problem (you're not being evaluated on mathematics after all). You typically have to use other algorithms and/or data structures in the problem.
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Zero values. This always gets people.
|
||||
|
||||
## Techniques
|
||||
|
||||
### Distance between two points
|
||||
|
||||
When comparing the between two points, using dx<sup>2</sup> + dy<sup>2</sup> is sufficient. It is unnecessary to square root the value. Examples: [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin/)
|
||||
|
||||
### Overlapping circles
|
||||
|
||||
To find out if two circles overlap, check that the distance between the two centers of the circles is less than the sum of their radii.
|
||||
|
||||
### Overlapping rectangles
|
||||
|
||||
Two rectangles overlap if the following is true:
|
||||
|
||||
```py
|
||||
overlap = rect_a.left < rect_b.right and \
|
||||
rect_a.right > rect_b.left and \
|
||||
rect_a.top > rect_b.bottom and \
|
||||
rect_a.bottom < rect_b.top
|
||||
```
|
||||
|
||||
Here's a [nice visualization](https://silentmatt.com/rectangle-intersection/). Examples: [Rectangle Overlap](https://leetcode.com/problems/rectangle-overlap/)
|
||||
|
||||
## Sample questions
|
||||
|
||||
- You have a plane with lots of rectangles on it, find out how many of them intersect.
|
||||
- Which data structure would you use to query the k-nearest points of a set on a 2D plane?
|
||||
- Given many points, find k points that are closest to the origin.
|
||||
- How would you triangulate a polygon?
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Rectangle Overlap](https://leetcode.com/problems/rectangle-overlap/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin/)
|
||||
- [Rectangle Area](https://leetcode.com/problems/rectangle-area/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
223
apps/website/contents/algorithms/graph.md
Normal file
223
apps/website/contents/algorithms/graph.md
Normal file
@@ -0,0 +1,223 @@
|
||||
---
|
||||
id: graph
|
||||
title: Graph cheatsheet for coding interviews
|
||||
description: Graph study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
graph coding interview study guide,
|
||||
graph tips for coding interviews,
|
||||
graph practice questions,
|
||||
graph useful techniques,
|
||||
graph time complexity,
|
||||
graph recommended study resources,
|
||||
]
|
||||
sidebar_label: Graph
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-graph.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
A graph is a structure containing a set of objects (nodes or vertices) where there can be edges between these nodes/vertices. Edges can be directed or undirected and can optionally have values (a weighted graph). Trees are undirected graphs in which any two vertices are connected by exactly one edge and there can be no cycles in the graph.
|
||||
|
||||
Graphs are commonly used to model relationship between unordered entities, such as
|
||||
|
||||
- Friendship between people - Each node is a person and edges between nodes represent that these two people are friends.
|
||||
- Distances between locations - Each node is a location and the edge between nodes represent that these locations are connected. The value of the edge represent the distance.
|
||||
|
||||
Be familiar with the various graph representations, graph search algorithms and their time and space complexities.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [From Theory To Practice: Representing Graphs](https://medium.com/basecs/from-theory-to-practice-representing-graphs-cfd782c5be38), basecs
|
||||
- [Deep Dive Through A Graph: DFS Traversal](https://medium.com/basecs/deep-dive-through-a-graph-dfs-traversal-8177df5d0f13), basecs
|
||||
- [Going Broad In A Graph: BFS Traversal](https://medium.com/basecs/going-broad-in-a-graph-bfs-traversal-959bd1a09255), basecs
|
||||
- Additional (only if you have time)
|
||||
- [Finding The Shortest Path, With A Little Help From Dijkstra](https://medium.com/basecs/finding-the-shortest-path-with-a-little-help-from-dijkstra-613149fbdc8e), basecs
|
||||
- [Spinning Around In Cycles With Directed Acyclic Graphs](https://medium.com/basecs/spinning-around-in-cycles-with-directed-acyclic-graphs-a233496d4688), basecs
|
||||
|
||||
## Graph representations
|
||||
|
||||
You can be given a list of edges and you have to build your own graph from the edges so that you can perform a traversal on them. The common graph representations are:
|
||||
|
||||
- Adjacency matrix
|
||||
- Adjacency list
|
||||
- Hash table of hash tables
|
||||
|
||||
Using a hash table of hash table would be the simplest approach during algorithm interviews. It will be rare that you have to use adjacency matrix or list for graph questions during interviews.
|
||||
|
||||
In algorithm interviews, graphs are commonly given in the input as 2D matrices where cells are the nodes and each cell can traverse to its adjacent cells (up/down/left/right). Hence it is important that you be familiar with traversing a 2D matrix. When traversing the matrix, always ensure that your current position is within the boundary of the matrix and has not been visited before.
|
||||
|
||||
## Time complexity
|
||||
|
||||
`|V|` is the number of vertices while `|E|` is the number of edges.
|
||||
|
||||
| Algorithm | Big-O |
|
||||
| -------------------- | -------------------------------- |
|
||||
| Depth-first search | O(|V| + |E|) |
|
||||
| Breadth-first search | O(|V| + |E|) |
|
||||
| Topological sort | O(|V| + |E|) |
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
- A tree-like diagram could very well be a graph that allows for cycles and a naive recursive solution would not work. In that case you will have to handle cycles and keep a set of visited nodes when traversing.
|
||||
- Ensure you are correctly keeping track of visited nodes and not visiting each node more than once. Otherwise your code could end up in an infinite loop.
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty graph
|
||||
- Graph with one or two nodes
|
||||
- Disjoint graphs
|
||||
- Graph with cycles
|
||||
|
||||
## Graph search algorithms
|
||||
|
||||
- **Common** - Breadth-first Search, Depth-first Search
|
||||
- **Uncommon** - Topological Sort, Dijkstra's algorithm
|
||||
- **Almost never** - Bellman-Ford algorithm, Floyd-Warshall algorithm, Prim's algorithm, Kruskal's algorithm. Your interviewer likely don't know them either.
|
||||
|
||||
### Depth-first search
|
||||
|
||||
Depth-first search is a graph traversal algorithm which explores as far as possible along each branch before backtracking. A stack is usually used to keep track of the nodes that are on the current search path. This can be done either by an implicit [recursion](./recursion.md) stack, or an actual [stack](./stack.md) data structure.
|
||||
|
||||
A simple template for doing depth-first searches on a matrix goes like this:
|
||||
|
||||
```py
|
||||
def dfs(matrix):
|
||||
# Check for an empty matrix/graph.
|
||||
if not matrix:
|
||||
return []
|
||||
|
||||
rows, cols = len(matrix), len(matrix[0])
|
||||
visited = set()
|
||||
directions = ((0, 1), (0, -1), (1, 0), (-1, 0))
|
||||
|
||||
def traverse(i, j):
|
||||
if (i, j) in visited:
|
||||
return
|
||||
|
||||
visited.add((i, j))
|
||||
# Traverse neighbors.
|
||||
for direction in directions:
|
||||
next_i, next_j = i + direction[0], j + direction[1]
|
||||
if 0 <= next_i < rows and 0 <= next_j < cols:
|
||||
# Add in question-specific checks, where relevant.
|
||||
traverse(next_i, next_j)
|
||||
|
||||
for i in range(rows):
|
||||
for j in range(cols):
|
||||
traverse(i, j)
|
||||
```
|
||||
|
||||
### Breadth-first search
|
||||
|
||||
Breadth-first search is a graph traversal algorithm which starts at a node and explores all nodes at the present depth, before moving on to the nodes at the next depth level. A [queue](./queue.md) is usually used to keep track of the nodes that were encountered but not yet explored.
|
||||
|
||||
A similar template for doing breadth-first searches on the matrix goes like this. It is important to use double-ended queues and not arrays/Python lists as enqueuing for double-ended queues is O(1) but it's O(n) for arrays.
|
||||
|
||||
```py
|
||||
from collections import deque
|
||||
|
||||
def bfs(matrix):
|
||||
# Check for an empty matrix/graph.
|
||||
if not matrix:
|
||||
return []
|
||||
|
||||
rows, cols = len(matrix), len(matrix[0])
|
||||
visited = set()
|
||||
directions = ((0, 1), (0, -1), (1, 0), (-1, 0))
|
||||
|
||||
def traverse(i, j):
|
||||
queue = deque([(i, j)])
|
||||
while queue:
|
||||
curr_i, curr_j = queue.popleft()
|
||||
if (curr_i, curr_j) not in visited:
|
||||
visited.add((curr_i, curr_j))
|
||||
# Traverse neighbors.
|
||||
for direction in directions:
|
||||
next_i, next_j = curr_i + direction[0], curr_j + direction[1]
|
||||
if 0 <= next_i < rows and 0 <= next_j < cols:
|
||||
# Add in question-specific checks, where relevant.
|
||||
queue.append((next_i, next_j))
|
||||
|
||||
for i in range(rows):
|
||||
for j in range(cols):
|
||||
traverse(i, j)
|
||||
```
|
||||
|
||||
:::info
|
||||
|
||||
While DFS is implemented using recursion in this sample, it could also be implemented iteratively similar to BFS. The key difference between the algorithms lies in the underlying data structure (BFS uses a queue while DFS uses a stack). The `deque` class in Python can function as both a stack and a queue.
|
||||
|
||||
:::
|
||||
|
||||
For additional tips on BFS and DFS, you can refer to this [LeetCode post](https://leetcode.com/problems/pacific-atlantic-water-flow/discuss/90774/Python-solution-with-detailed-explanation)
|
||||
|
||||
### Topological sorting
|
||||
|
||||
A topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering. Precisely, a topological sort is a graph traversal in which each node v is visited only after all its dependencies are visited.
|
||||
|
||||
Topological sorting is most commonly used for job scheduling a sequence of jobs or tasks which has dependencies on other jobs/tasks. The jobs are represented by vertices, and there is an edge from x to y if job x must be completed before job y can be started.
|
||||
|
||||
Another example is taking courses in university where courses have pre-requisites.
|
||||
|
||||
Here's an example where the edges is an array of two-value tuples and the first value depends on the second value.
|
||||
|
||||
```py
|
||||
def graph_topo_sort(num_nodes, edges):
|
||||
from collections import deque
|
||||
nodes, order, queue = {}, [], deque()
|
||||
for node_id in range(num_nodes):
|
||||
nodes[node_id] = { 'in': 0, 'out': set() }
|
||||
for node_id, pre_id in edges:
|
||||
nodes[node_id]['in'] += 1
|
||||
nodes[pre_id]['out'].add(node_id)
|
||||
for node_id in nodes.keys():
|
||||
if nodes[node_id]['in'] == 0:
|
||||
queue.append(node_id)
|
||||
while len(queue):
|
||||
node_id = queue.pop()
|
||||
for outgoing_id in nodes[node_id]['out']:
|
||||
nodes[outgoing_id]['in'] -= 1
|
||||
if nodes[outgoing_id]['in'] == 0:
|
||||
queue.append(outgoing_id)
|
||||
order.append(node_id)
|
||||
return order if len(order) == num_nodes else None
|
||||
|
||||
print(graph_topo_sort(4, [[0, 1], [0, 2], [2, 1], [3, 0]]))
|
||||
# [1, 2, 0, 3]
|
||||
```
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Number of Islands](https://leetcode.com/problems/number-of-islands/)
|
||||
- [Flood Fill](https://leetcode.com/problems/flood-fill)
|
||||
- [01 Matrix](https://leetcode.com/problems/01-matrix/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- Breadth-first search
|
||||
- [Rotting Oranges](https://leetcode.com/problems/rotting-oranges/)
|
||||
- [Minimum Knight Moves (LeetCode Premium)](https://leetcode.com/problems/minimum-knight-moves)
|
||||
- Either search
|
||||
- [Clone Graph](https://leetcode.com/problems/clone-graph/)
|
||||
- [Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow/)
|
||||
- [Number of Connected Components in an Undirected Graph (LeetCode Premium)](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/)
|
||||
- [Graph Valid Tree (LeetCode Premium)](https://leetcode.com/problems/graph-valid-tree/)
|
||||
- Topological sorting
|
||||
- [Course Schedule](https://leetcode.com/problems/course-schedule/)
|
||||
- [Alien Dictionary (LeetCode Premium)](https://leetcode.com/problems/alien-dictionary/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
87
apps/website/contents/algorithms/hash-table.md
Normal file
87
apps/website/contents/algorithms/hash-table.md
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
id: hash-table
|
||||
title: Hash table cheatsheet for coding interviews
|
||||
description: Hash table study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
hash table coding interview study guide,
|
||||
hash table tips for coding interviews,
|
||||
hash table practice questions,
|
||||
hash table useful techniques,
|
||||
hash table time complexity,
|
||||
hash table recommended study resources,
|
||||
]
|
||||
sidebar_label: Hash table
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-hash-table.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
A hash table (commonly referred to as hash map) is a data structure that implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function on an element to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found. During lookup, the key is hashed and the resulting hash indicates where the corresponding value is stored.
|
||||
|
||||
Hashing is the most common example of a space-time tradeoff. Instead of linearly searching an array every time to determine if an element is present, which takes O(n) time, we can traverse the array once and hash all the elements into a hash table. Determining if the element is present is a simple matter of hashing the element and seeing if it exists in the hash table, which is O(1) on average.
|
||||
|
||||
In the case of hash collisions, there are a number of collision resolution techniques that can be used. You will unlikely be asked about details of collision resolution techniques in interviews:
|
||||
|
||||
- **Separate chaining** - A linked list is used for each value, so that it stores all the collided items.
|
||||
- **Open addressing** - All entry records are stored in the bucket array itself. When a new entry has to be inserted, the buckets are examined, starting with the hashed-to slot and proceeding in some probe sequence, until an unoccupied slot is found.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [Taking Hash Tables Off The Shelf](https://medium.com/basecs/taking-hash-tables-off-the-shelf-139cbf4752f0), basecs
|
||||
- [Hashing Out Hash Functions](https://medium.com/basecs/hashing-out-hash-functions-ea5dd8beb4dd), basecs
|
||||
- Videos
|
||||
- [Core: Hash Tables](https://www.coursera.org/lecture/data-structures-optimizing-performance/core-hash-tables-m7UuP), University of California San Diego
|
||||
|
||||
## Implementations
|
||||
|
||||
| Language | API |
|
||||
| --- | --- |
|
||||
| C++ | [`std::unordered_map`](https://docs.microsoft.com/en-us/cpp/standard-library/unordered-map) |
|
||||
| Java | [`java.util.Map`](https://docs.oracle.com/javase/10/docs/api/java/util/Map.html). Use [`java.util.HashMap`](https://docs.oracle.com/javase/10/docs/api/java/util/HashMap.html) or [`java.util.TreeMap`](https://docs.oracle.com/javase/10/docs/api/java/util/TreeMap.html) (preferred) |
|
||||
| Python | [`dict`](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) |
|
||||
| JavaScript | [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) or [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) |
|
||||
|
||||
## Time complexity
|
||||
|
||||
| Operation | Big-O | Note |
|
||||
| --------- | ------ | ---------------------------------------------------- |
|
||||
| Access | N/A | Accessing not possible as the hash code is not known |
|
||||
| Search | O(1)\* | |
|
||||
| Insert | O(1)\* | |
|
||||
| Remove | O(1)\* | |
|
||||
|
||||
_\* This is the average case, but in interviews we only care about the average case for hash tables._
|
||||
|
||||
## Sample questions
|
||||
|
||||
- Describe an implementation of a least-used cache, and big-O notation of it.
|
||||
- A question involving an API's integration with hash map where the buckets of hash map are made up of linked lists.
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Two Sum](https://leetcode.com/problems/two-sum)
|
||||
- [Ransom Note](https://leetcode.com/problems/ransom-note)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Group Anagrams](https://leetcode.com/problems/group-anagrams/)
|
||||
- [Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o1/)
|
||||
- [First Missing Positive](https://leetcode.com/problems/first-missing-positive/)
|
||||
- [LRU Cache](https://leetcode.com/problems/lru-cache/)
|
||||
- [All O one Data Structure](https://leetcode.com/problems/all-oone-data-structure/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
81
apps/website/contents/algorithms/heap.md
Normal file
81
apps/website/contents/algorithms/heap.md
Normal file
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: heap
|
||||
title: Heap cheatsheet for coding interviews
|
||||
description: Heap study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
heap coding interview study guide,
|
||||
heap tips for coding interviews,
|
||||
heap practice questions,
|
||||
heap useful techniques,
|
||||
heap time complexity,
|
||||
heap recommended study resources,
|
||||
]
|
||||
sidebar_label: Heap
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-heap.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
A heap is a specialized tree-based data structure which is a complete tree that satisfies the heap property.
|
||||
|
||||
- Max heap - In a max heap the value of a node must be greatest among the node values in its entire subtree. The same property must be recursively true for all nodes in the tree.
|
||||
- Min heap - In a min heap the value of a node must be smallest among the node values in its entire subtree. The same property must be recursively true for all nodes in the tree.
|
||||
|
||||
In the context of algorithm interviews, heaps and priority queues can be treated as the same data structure. A heap is a useful data structure when it is necessary to repeatedly remove the object with the highest (or lowest) priority, or when insertions need to be interspersed with removals of the root node.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- [Learning to Love Heaps](https://medium.com/basecs/learning-to-love-heaps-cef2b273a238), basecs
|
||||
- [Heapify All The Things With Heap Sort](https://medium.com/basecs/heapify-all-the-things-with-heap-sort-55ee1c93af82), basecs
|
||||
- [Heaps](http://www.cs.yale.edu/homes/aspnes/classes/223/notes.html#heaps), James Aspnes, Yale University
|
||||
|
||||
## Implementations
|
||||
|
||||
| Language | API |
|
||||
| --- | --- |
|
||||
| C++ | [`std::priority_queue`](https://docs.microsoft.com/en-us/cpp/standard-library/priority-queue-class) |
|
||||
| Java | [`java.util.PriorityQueue`](https://docs.oracle.com/javase/10/docs/api/java/util/PriorityQueue.html) |
|
||||
| Python | [`heapq`](https://docs.python.org/library/heapq.html) |
|
||||
| JavaScript | N/A |
|
||||
|
||||
## Time complexity
|
||||
|
||||
| Operation | Big-O |
|
||||
| ------------------------------------------------------ | --------- |
|
||||
| Find max/min | O(1) |
|
||||
| Insert | O(log(n)) |
|
||||
| Remove | O(log(n)) |
|
||||
| Heapify (create a heap out of given array of elements) | O(n) |
|
||||
|
||||
## Techniques
|
||||
|
||||
### Mention of `k`
|
||||
|
||||
If you see a top or lowest _k_ being mentioned in the question, it is usually a signal that a heap can be used to solve the problem, such as in [Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements/).
|
||||
|
||||
If you require the top _k_ elements use a Min Heap of size _k_. Iterate through each element, pushing it into the heap (for python `heapq`, invert the value before pushing to find the max). Whenever the heap size exceeds _k_, remove the minimum element, that will guarantee that you have the _k_ largest elements.
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Merge K Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)
|
||||
- [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements/)
|
||||
- [Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
86
apps/website/contents/algorithms/interval.md
Normal file
86
apps/website/contents/algorithms/interval.md
Normal file
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: interval
|
||||
title: Interval cheatsheet for coding interviews
|
||||
description: Interval study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
interval coding interview study guide,
|
||||
interval tips for coding interviews,
|
||||
interval practice questions,
|
||||
interval useful techniques,
|
||||
interval time complexity,
|
||||
interval recommended study resources,
|
||||
]
|
||||
sidebar_label: Interval
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-interval.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Interval questions are a subset of [array](./array.md) questions where you are given an array of two-element arrays (an interval) and the two values represent a start and an end value. Interval questions are considered part of the array family but they involve some common techniques hence they are extracted out to this special section of their own.
|
||||
|
||||
An example interval array: `[[1, 2], [4, 7]]`.
|
||||
|
||||
Interval questions can be tricky to those who have not tried them before because of the sheer number of cases to consider when they overlap.
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
- Clarify with the interviewer whether `[1, 2]` and `[2, 3]` are considered overlapping intervals as it affects how you will write your equality checks.
|
||||
- Clarify whether an interval of `[a, b]` will strictly follow `a` < `b` (`a` is smaller than `b`)
|
||||
|
||||
## Corner cases
|
||||
|
||||
- No intervals
|
||||
- Single interval
|
||||
- Two intervals
|
||||
- Non-overlapping intervals
|
||||
- An interval totally consumed within another interval
|
||||
- Duplicate intervals (exactly the same start and end)
|
||||
- Intervals which start right where another interval ends - `[[1, 2], [2, 3]]`
|
||||
|
||||
## Techniques
|
||||
|
||||
### Sort the array of intervals by its starting point
|
||||
|
||||
A common routine for interval questions is to sort the array of intervals by each interval's starting value. This step is crucial to solving the [Merge Intervals](https://leetcode.com/problems/merge-intervals/) question.
|
||||
|
||||
### Checking if two intervals overlap
|
||||
|
||||
Be familiar with writing code to check if two intervals overlap.
|
||||
|
||||
```py
|
||||
def is_overlap(a, b):
|
||||
return a[0] < b[1] and b[0] < a[1]
|
||||
```
|
||||
|
||||
### Merging two intervals
|
||||
|
||||
```py
|
||||
def merge_overlapping_intervals(a, b):
|
||||
return [min(a[0], b[0]), max(a[1], b[1])]
|
||||
```
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Merge Intervals](https://leetcode.com/problems/merge-intervals/)
|
||||
- [Insert Interval](https://leetcode.com/problems/insert-interval/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Non-overlapping Intervals](https://leetcode.com/problems/non-overlapping-intervals/)
|
||||
- [Meeting Rooms (LeetCode Premium)](https://leetcode.com/problems/meeting-rooms/)
|
||||
- [Meeting Rooms II (LeetCode Premium)](https://leetcode.com/problems/meeting-rooms-ii/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
143
apps/website/contents/algorithms/linked-list.md
Normal file
143
apps/website/contents/algorithms/linked-list.md
Normal file
@@ -0,0 +1,143 @@
|
||||
---
|
||||
id: linked-list
|
||||
title: Linked list cheatsheet for coding interviews
|
||||
description: Linked list study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
linked list coding interview study guide,
|
||||
linked list tips for coding interviews,
|
||||
linked list practice questions,
|
||||
linked list useful techniques,
|
||||
linked list time complexity,
|
||||
linked list recommended study resources,
|
||||
]
|
||||
sidebar_label: Linked list
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-linked-list.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Like arrays, a linked list is used to represent sequential data. It is a linear collection of data elements whose order is not given by their physical placement in memory, as opposed to arrays, where data is stored in sequential blocks of memory. Instead, each element contains an address of the next element. It is a data structure consisting of a collection of nodes which together represent a sequence.
|
||||
|
||||
In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence.
|
||||
|
||||
**Advantages**
|
||||
|
||||
Insertion and deletion of a node in the list (given its location) is O(1) whereas in arrays the following elements will have to be shifted.
|
||||
|
||||
**Disadvantages**
|
||||
|
||||
Access time is linear because directly accessing elements by its position in the list is not possible (in arrays you can do `arr[4]` for example). You have to traverse from the start.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [What's a Linked List, Anyway? [Part 1]](https://medium.com/basecs/whats-a-linked-list-anyway-part-1-d8b7e6508b9d), basecs
|
||||
- [What's a Linked List, Anyway? [Part 2]](https://medium.com/basecs/whats-a-linked-list-anyway-part-2-131d96f71996), basecs
|
||||
- Videos
|
||||
- [Singly-linked lists](https://www.coursera.org/lecture/data-structures/singly-linked-lists-kHhgK), University of California San Diego
|
||||
- [Doubly linked lists](https://www.coursera.org/lecture/data-structures/doubly-linked-lists-jpGKD), University of California San Diego
|
||||
|
||||
## Types of linked lists
|
||||
|
||||
### Singly linked list
|
||||
|
||||
A linked list where each node points to the next node and the last node points to `null`.
|
||||
|
||||
### Doubly linked list
|
||||
|
||||
A linked list where each node has two pointers, `next` which points to the next node and `prev` which points to the previous node. The `prev` pointer of the first node and the `next` pointer of the last node point to `null`.
|
||||
|
||||
### Circular linked list
|
||||
|
||||
A singly linked list where the last node points back to the first node. There is a circular doubly linked list variant where the `prev` pointer of the first node points to the last node and the `next` pointer of the last node points to the first node.
|
||||
|
||||
## Implementations
|
||||
|
||||
Out of the common languages, only Java provides a linked list implementation. Thankfully it's easy to write your own linked list regardless of language.
|
||||
|
||||
| Language | API |
|
||||
| --- | --- |
|
||||
| C++ | N/A |
|
||||
| Java | [`java.util.LinkedList`](https://docs.oracle.com/javase/10/docs/api/java/util/LinkedList.html) |
|
||||
| Python | N/A |
|
||||
| JavaScript | N/A |
|
||||
|
||||
## Time complexity
|
||||
|
||||
| Operation | Big-O | Note |
|
||||
| --------- | ----- | ---------------------------------------------------- |
|
||||
| Access | O(n) | |
|
||||
| Search | O(n) | |
|
||||
| Insert | O(1) | Assumes you have traversed to the insertion position |
|
||||
| Remove | O(1) | Assumes you have traversed to the node to be removed |
|
||||
|
||||
## Common routines
|
||||
|
||||
Be familiar with the following routines because many linked list questions make use of one or more of these routines in the solution:
|
||||
|
||||
- Counting the number of nodes in the linked list
|
||||
- Reversing a linked list in-place
|
||||
- Finding the middle node of the linked list using two pointers (fast/slow)
|
||||
- Merging two linked lists together
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty linked list (head is `null`)
|
||||
- Single node
|
||||
- Two nodes
|
||||
- Linked list has cycles. **Tip:** Clarify beforehand with the interviewer whether there can be a cycle in the list. Usually the answer is no and you don't have to handle it in the code
|
||||
|
||||
## Techniques
|
||||
|
||||
### Sentinel/dummy nodes
|
||||
|
||||
Adding a sentinel/dummy node at the head and/or tail might help to handle many edge cases where operations have to be performed at the head or the tail. The presence of dummy nodes essentially ensures that operations will never have be done on the head or the tail, thereby removing a lot of headache in writing conditional checks to dealing with null pointers. Be sure to remember to remove them at the end of the operation.
|
||||
|
||||
### Two pointers
|
||||
|
||||
Two pointer approaches are also common for linked lists. This approach is used for many classic linked list problems.
|
||||
|
||||
- Getting the k<sup>th</sup> from last node - Have two pointers, where one is k nodes ahead of the other. When the node ahead reaches the end, the other node is k nodes behind
|
||||
- Detecting cycles - Have two pointers, where one pointer increments twice as much as the other, if the two pointers meet, means that there is a cycle
|
||||
- Getting the middle node - Have two pointers, where one pointer increments twice as much as the other. When the faster node reaches the end of the list, the slower node will be at the middle
|
||||
|
||||
### Using space
|
||||
|
||||
Many linked list problems can be easily solved by creating a new linked list and adding nodes to the new linked list with the final result. However, this takes up extra space and makes the question much less challenging. The interviewer will usually request that you modify the linked list in-place and the solve the problem without additional storage. You can borrow ideas from the [Reverse a Linked List](https://leetcode.com/problems/reverse-linked-list/) problem.
|
||||
|
||||
### Elegant modification operations
|
||||
|
||||
As mentioned earlier, a linked list's non-sequential nature of memory allows for efficient modification of its contents. Unlike arrays where you can only modify the value at a position, for linked lists you can also modify the `next` pointer in addition to the `value`.
|
||||
|
||||
Here are some common operations and how they can be achieved easily:
|
||||
|
||||
- Truncate a list - Set the `next` pointer to `null` at the last element
|
||||
- Swapping values of nodes - Just like arrays, just swap the value of the two nodes, there's no need to swap the `next` pointer
|
||||
- Combining two lists - attach the head of the second list to the tail of the first list
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Reverse a Linked List](https://leetcode.com/problems/reverse-linked-list/)
|
||||
- [Detect Cycle in a Linked List](https://leetcode.com/problems/linked-list-cycle/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists/)
|
||||
- [Merge K Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)
|
||||
- [Remove Nth Node From End Of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/)
|
||||
- [Reorder List](https://leetcode.com/problems/reorder-list/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
80
apps/website/contents/algorithms/math.md
Normal file
80
apps/website/contents/algorithms/math.md
Normal file
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: math
|
||||
title: Math cheatsheet for coding interviews
|
||||
description: Math study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
math coding interview study guide,
|
||||
math tips for coding interviews,
|
||||
math practice questions,
|
||||
math useful techniques,
|
||||
math time complexity,
|
||||
math recommended study resources,
|
||||
]
|
||||
sidebar_label: Math
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-math.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Math is a foundational aspect of Computer Science and every programmer and computer scientist needs to have basic mathematical knowledge. Thankfully, for the purpose of coding interviews, there usually won't be that much math involved, but some basic math techniques is helpful to know as you may be asked to implement mathematical operations.
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
- If code involves division or modulo, remember to check for division or modulo by 0 case.
|
||||
- Check for and handle overflow/underflow if you are using a typed language like Java and C++. At the very least, mention that overflow/underflow is possible and ask whether you need to handle it.
|
||||
- Consider negative numbers and floating point numbers. This may sound obvious, but under interview pressure, many obvious cases go unnoticed.
|
||||
|
||||
## Common formulas
|
||||
|
||||
| | Formula |
|
||||
| --- | --- |
|
||||
| Check if a number is even | `num % 2 == 0` |
|
||||
| Sum of 1 to N | 1 + 2 + ... + (N - 1) + N = (N+1) \* N/2 |
|
||||
| Sum of Geometric Progression | 2<sup>0</sup> + 2<sup>1</sup> + 2<sup>2</sup> + 2<sup>3</sup> + ... 2<sup>n</sup> = 2<sup>n+1</sup> - 1 |
|
||||
| Permutations of N | N! / (N-K)! |
|
||||
| Combinations of N | N! / (K! \* (N-K)!) |
|
||||
|
||||
## Techniques
|
||||
|
||||
### Multiples of a number
|
||||
|
||||
When a question involves "whether a number is a multiple of X", the modulo operator would be useful.
|
||||
|
||||
### Comparing floats
|
||||
|
||||
When dealing with floating point numbers, take note of rounding mistakes. Consider using epsilon comparisons instead of equality checks. E.g. `abs(x - y) <= 1e-6` instead of `x == y`.
|
||||
|
||||
### Fast operators
|
||||
|
||||
If the question asks you to implement an operator such as power, square root or division and want it to be faster than O(n), some sort of doubling (fast exponentiation) or halving (binary search) is usually the approach to go. Examples: [Pow(x, n)](https://leetcode.com/problems/powx-n/), [Sqrt(x)](https://leetcode.com/problems/sqrtx/)
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Division by 0
|
||||
- Multiplication by 1
|
||||
- Negative numbers
|
||||
- Floats
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Pow(x, n)](https://leetcode.com/problems/powx-n/)
|
||||
- [Sqrt(x)](https://leetcode.com/problems/sqrtx/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Integer to English Words](https://leetcode.com/problems/integer-to-english-words/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
83
apps/website/contents/algorithms/matrix.md
Normal file
83
apps/website/contents/algorithms/matrix.md
Normal file
@@ -0,0 +1,83 @@
|
||||
---
|
||||
id: matrix
|
||||
title: Matrix cheatsheet for coding interviews
|
||||
description: Matrix study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
matrix coding interview study guide,
|
||||
matrix tips for coding interviews,
|
||||
matrix practice questions,
|
||||
matrix useful techniques,
|
||||
matrix time complexity,
|
||||
matrix recommended study resources,
|
||||
]
|
||||
sidebar_label: Matrix
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-matrix.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
A matrix is a 2-dimensional array. Questions involving matrices are usually related to [dynamic programming](./dynamic-programming.md) or [graph](./graph.md) traversal.
|
||||
|
||||
Matrices can be used to represent graphs where each node is a cell on the matrix which has 4 neighbors (except those cells on the edge and corners). This page will focus on questions which don't use matrix as graphs. Questions which are meant to use the matrix as a graph can be found on the [graph section](./graph.md).
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty matrix. Check that none of the arrays are 0 length
|
||||
- 1 x 1 matrix
|
||||
- Matrix with only one row or column
|
||||
|
||||
## Techniques
|
||||
|
||||
### Creating an empty N x M matrix
|
||||
|
||||
For questions involving traversal or dynamic programming, you almost always want to make a copy of the matrix with the same size/dimensions that is initialized to empty values to store the visited state or dynamic programming table. Be familiar with such a routine in your language of choice:
|
||||
|
||||
This can be done easily in Python in one line.
|
||||
|
||||
```py
|
||||
# Assumes that the matrix is non-empty
|
||||
zero_matrix = [[0 for _ in range(len(matrix[0]))] for _ in range(len(matrix))]
|
||||
```
|
||||
|
||||
Copying a matrix in Python is:
|
||||
|
||||
```py
|
||||
copied_matrix = [row[:] for row in matrix]
|
||||
```
|
||||
|
||||
### Transposing a matrix
|
||||
|
||||
The transpose of a matrix is found by interchanging its rows into columns or columns into rows.
|
||||
|
||||
Many grid-based games can be modeled as a matrix, such as Tic-Tac-Toe, Sudoku, Crossword, Connect 4, Battleship, etc. It is not uncommon to be asked to verify the winning condition of the game. For games like Tic-Tac-Toe, Connect 4 and Crosswords, where verification has to be done vertically and horizontally, one trick is to write code to verify the matrix for the horizontal cells, transpose the matrix, and reuse the logic for horizontal verification to verify originally vertical cells (which are now horizontal).
|
||||
|
||||
Transposing a matrix in Python is simply:
|
||||
|
||||
```py
|
||||
transposed_matrix = zip(*matrix)
|
||||
```
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes/)
|
||||
- [Spiral Matrix](https://leetcode.com/problems/spiral-matrix/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Rotate Image](https://leetcode.com/problems/rotate-image/)
|
||||
- [Valid Sudoku](https://leetcode.com/problems/valid-sudoku/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
19
apps/website/contents/algorithms/oop.md
Normal file
19
apps/website/contents/algorithms/oop.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
id: oop
|
||||
title: Object-oriented programming
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
## Sample questions
|
||||
|
||||
- How would you design a chess game? What classes and objects would you use? What methods would they have?
|
||||
- How would you design the data structures for a book keeping system for a library?
|
||||
- Explain how you would design a HTTP server? Give examples of classes, methods, and interfaces. What are the challenges here?
|
||||
- Discuss algorithms and data structures for a garbage collector?
|
||||
- How would you implement an HR system to keep track of employee salaries and benefits?
|
||||
- How would you implement an Elevator system?
|
||||
- How would you implement a Parking Lot system?
|
||||
|
||||
## Recommended courses
|
||||
|
||||
- [Grokking the Object Oriented Design Interview](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-object-oriented-design-interview)
|
||||
84
apps/website/contents/algorithms/queue.md
Normal file
84
apps/website/contents/algorithms/queue.md
Normal file
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: queue
|
||||
title: Queue cheatsheet for coding interviews
|
||||
description: Queue study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
queue coding interview study guide,
|
||||
queue tips for coding interviews,
|
||||
queue practice questions,
|
||||
queue useful techniques,
|
||||
queue time complexity,
|
||||
queue recommended study resources,
|
||||
]
|
||||
sidebar_label: Queue
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-queue.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
A queue is a linear collection of elements that are maintained in a sequence and can be modified by the addition of elements at one end of the sequence (**enqueue** operation) and the removal of elements from the other end (**dequeue** operation). Usually, the end of the sequence at which elements are added is called the back, tail, or rear of the queue, and the end at which elements are removed is called the head or front of the queue. As an abstract data type, queues can be implemented using arrays or singly linked lists.
|
||||
|
||||
This behavior is commonly called FIFO (first in, first out). The name "queue" for this type of structure comes from the analogy to people lining up in real life to wait for goods or services.
|
||||
|
||||
Breadth-first search is commonly implemented using queues.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [To Queue Or Not To Queue](https://medium.com/basecs/to-queue-or-not-to-queue-2653bcde5b04), basecs
|
||||
- Videos
|
||||
- [Queues](https://www.coursera.org/lecture/data-structures/queues-EShpq), University of California San Diego
|
||||
|
||||
## Implementations
|
||||
|
||||
| Language | API |
|
||||
| --- | --- |
|
||||
| C++ | [`std::queue`](https://docs.microsoft.com/en-us/cpp/standard-library/queue-class) |
|
||||
| Java | [`java.util.Queue`](https://docs.oracle.com/javase/10/docs/api/java/util/Queue.html).Use [`java.util.ArrayDeque`](https://docs.oracle.com/javase/10/docs/api/java/util/ArrayDeque.html) |
|
||||
| Python | [`queue`](https://docs.python.org/3/library/queue.html) |
|
||||
| JavaScript | N/A |
|
||||
|
||||
## Time complexity
|
||||
|
||||
| Operation | Big-O |
|
||||
| ------------- | ----- |
|
||||
| Enqueue/Offer | O(1) |
|
||||
| Dequeue/Poll | O(1) |
|
||||
| Front | O(1) |
|
||||
| Back | O(1) |
|
||||
| isEmpty | O(1) |
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
Most languages don't have a built in Queue class which to be used, and candidates often use arrays (JavaScript) or lists (Python) as a queue. However, note that the enqueue operation in such a scenario will be O(n) because it requires shifting of all other elements by one. In such cases, you can flag this to the interviewer and say that you assume that there's a queue data structure to use which has an efficient enqueue operation.
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty queue
|
||||
- Queue with one item
|
||||
- Queue with two items
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)
|
||||
- [Design Circular Queue](https://leetcode.com/problems/design-circular-queue)
|
||||
- [Design Hit Counter (LeetCode Premium)](https://leetcode.com/problems/design-hit-counter)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
95
apps/website/contents/algorithms/recursion.md
Normal file
95
apps/website/contents/algorithms/recursion.md
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
id: recursion
|
||||
title: Recursion cheatsheet for coding interviews
|
||||
description: Recursion study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
recursion coding interview study guide,
|
||||
recursion tips for coding interviews,
|
||||
recursion practice questions,
|
||||
recursion useful techniques,
|
||||
recursion time complexity,
|
||||
recursion recommended study resources,
|
||||
]
|
||||
sidebar_label: Recursion
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-recursion.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Recursion is a method of solving a computational problem where the solution depends on solutions to smaller instances of the same problem.
|
||||
|
||||
All recursive functions contains two parts:
|
||||
|
||||
1. A base case (or cases) defined, which defines when the recursion is stopped - otherwise it will go on forever!
|
||||
1. Breaking down the problem into smaller subproblems and invoking the recursive call
|
||||
|
||||
One of the most common example of recursion is the Fibonacci sequence.
|
||||
|
||||
- Base cases: `fib(0) = 0` and `fib(1) = 1`
|
||||
- Recurrence relation: `fib(i) = fib(i-1) + fib(i-2)`
|
||||
|
||||
```py
|
||||
def fib(n):
|
||||
if n <= 1:
|
||||
return n
|
||||
return fib(n - 1) + fib(n - 2)
|
||||
```
|
||||
|
||||
Many algorithms relevant in coding interviews make heavy use of recursion - binary search, merge sort, tree traversal, depth-first search, etc. In this article, we focus on questions which use recursion but aren't part of other well known algorithms.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [Recursion](https://www.cs.utah.edu/~germain/PPS/Topics/recursion.html), University of Utah
|
||||
- Videos
|
||||
- [Tail Recursion](https://www.coursera.org/lecture/programming-languages/tail-recursion-YZic1), University of Washington
|
||||
|
||||
<!-- TODO: Talk about backtracking -->
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
- Always remember to always define a base case so that your recursion will end.
|
||||
- Recursion is useful for permutation, because it generates all combinations and tree-based questions. You should know how to generate all permutations of a sequence as well as how to handle duplicates.
|
||||
- Recursion implicitly uses a stack. Hence all recursive approaches can be rewritten iteratively using a stack. Beware of cases where the recursion level goes too deep and causes a stack overflow (the default limit in Python is 1000). You may get bonus points for pointing this out to the interviewer. Recursion will never be O(1) space complexity because a stack is involved, unless there is [tail-call optimization](https://stackoverflow.com/questions/310974/what-is-tail-call-optimization) (TCO). Find out if your chosen language supports TCO.
|
||||
- Number of base cases - In the fibonacci example above, note that one of our recursive calls invoke `fib(n - 2)`. This indicates that you should have 2 base cases defined so that your code covers all possible invocations of the function within the input range. If your recursive function only invokes `fn(n - 1)`, then only one base case is needed
|
||||
|
||||
## Corner cases
|
||||
|
||||
- `n = 0`
|
||||
- `n = 1`
|
||||
- Make sure you have enough base cases to cover all possible invocations of the recursive function
|
||||
|
||||
## Techniques
|
||||
|
||||
### Memoization
|
||||
|
||||
In some cases, you may be computing the result for previously computed inputs. Let's look at the Fibonacci example again. `fib(5)` calls `fib(4)` and `fib(3)`, and `fib(4)` calls `fib(3)` and `fib(2)`. `fib(3)` is being called twice! If the value for `fib(3)` is memoized and used again, that greatly improves the efficiency of the algorithm and the time complexity becomes O(n).
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Generate Parentheses](https://leetcode.com/problems/generate-parentheses/)
|
||||
- [Combinations](https://leetcode.com/problems/combinations/)
|
||||
- [Subsets](https://leetcode.com/problems/subsets/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/)
|
||||
- [Subsets II](https://leetcode.com/problems/subsets-ii/)
|
||||
- [Permutations](https://leetcode.com/problems/permutations/)
|
||||
- [Sudoku Solver](https://leetcode.com/problems/sudoku-solver/)
|
||||
- [Strobogrammatic Number II (LeetCode Premium)](https://leetcode.com/problems/strobogrammatic-number-ii/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
107
apps/website/contents/algorithms/sorting-searching.md
Normal file
107
apps/website/contents/algorithms/sorting-searching.md
Normal file
@@ -0,0 +1,107 @@
|
||||
---
|
||||
id: sorting-searching
|
||||
title: Sorting and searching cheatsheet for coding interviews
|
||||
description: Sorting and searching study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
sorting searching coding interview study guide,
|
||||
sorting searching tips for coding interviews,
|
||||
sorting searching practice questions,
|
||||
sorting searching useful techniques,
|
||||
sorting searching time complexity,
|
||||
sorting searching recommended study resources,
|
||||
]
|
||||
sidebar_label: Sorting and searching
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-sorting-searching.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Sorting is the act of rearranging elements in a sequence in order, either in numerical or lexicographical order, and either ascending or descending.
|
||||
|
||||
A number of basic algorithms run in O(n<sup>2</sup>) and should not be used in interviews. In algorithm interviews, you're unlikely to need to implement any of the sorting algorithms from scratch. Instead you would need to sort the input using your language's default sorting function so that you can use binary searches on them.
|
||||
|
||||
On a sorted array of elements, by leveraging on its sorted property, searching can be done on them in faster than O(n) time by using a binary search. Binary search compares the target value with the middle element of the array, which informs the algorithm whether the target value lies in the left half or the right half, and this comparison proceeds on the remaining half until the target is found or the remaining half is empty.
|
||||
|
||||
## Learning resources
|
||||
|
||||
While you're unlikely to be asked to implement a sorting algorithm from scratch during an interview, it is good to know the various time complexities of the different sorting algorithms.
|
||||
|
||||
- Readings
|
||||
- [Sorting Out The Basics Behind Sorting Algorithms](https://medium.com/basecs/sorting-out-the-basics-behind-sorting-algorithms-b0a032873add), basecs
|
||||
- [Binary Search](https://www.khanacademy.org/computing/computer-science/algorithms/binary-search/), Khan Academy
|
||||
- Additional (only if you have time)
|
||||
- [Exponentially Easy Selection Sort](https://medium.com/basecs/exponentially-easy-selection-sort-d7a34292b049), basecs
|
||||
- [Bubbling Up With Bubble Sorts](https://medium.com/basecs/bubbling-up-with-bubble-sorts-3df5ac88e592), basecs
|
||||
- [Inching Towards Insertion Sort](https://medium.com/basecs/inching-towards-insertion-sort-9799274430da), basecs
|
||||
- [Making Sense of Merge Sort (Part 1)](https://medium.com/basecs/making-sense-of-merge-sort-part-1-49649a143478), basecs
|
||||
- [Making Sense of Merge Sort (Part 2)](https://medium.com/basecs/making-sense-of-merge-sort-part-2-be8706453209), basecs
|
||||
- [Pivoting To Understand Quicksort (Part 1)](https://medium.com/basecs/pivoting-to-understand-quicksort-part-1-75178dfb9313), basecs
|
||||
- [Pivoting To Understand Quicksort (Part 2)](https://medium.com/basecs/pivoting-to-understand-quicksort-part-2-30161aefe1d3), basecs
|
||||
- [Counting Linearly With Counting Sort](https://medium.com/basecs/counting-linearly-with-counting-sort-cd8516ae09b3), basecs
|
||||
- [Getting To The Root Of Sorting With Radix Sort](https://medium.com/basecs/getting-to-the-root-of-sorting-with-radix-sort-f8e9240d4224), basecs
|
||||
|
||||
## Time complexity
|
||||
|
||||
| Algorithm | Time | Space |
|
||||
| -------------- | ---------------- | --------- |
|
||||
| Bubble sort | O(n<sup>2</sup>) | O(1) |
|
||||
| Insertion sort | O(n<sup>2</sup>) | O(1) |
|
||||
| Selection sort | O(n<sup>2</sup>) | O(1) |
|
||||
| Quicksort | O(nlog(n)) | O(log(n)) |
|
||||
| Mergesort | O(nlog(n)) | O(n) |
|
||||
| Heapsort | O(nlog(n)) | O(1) |
|
||||
| Counting sort | O(n + k) | O(k) |
|
||||
| Radix sort | O(nk) | O(n + k) |
|
||||
|
||||
| Algorithm | Big-O |
|
||||
| ------------- | --------- |
|
||||
| Binary search | O(log(n)) |
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
Make sure you know the time and space complexity of the language's default sorting algorithm! The time complexity is almost definitely O(nlog(n))). Bonus points if you can name the sort. In Python, it's [Timsort](https://en.wikipedia.org/wiki/Timsort).
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty sequence
|
||||
- Sequence with one element
|
||||
- Sequence with two elements
|
||||
- Sequence containing duplicate elements.
|
||||
|
||||
## Techniques
|
||||
|
||||
### Sorted inputs
|
||||
|
||||
When a given sequence is in a sorted order (be it ascending or descending), using binary search should be one of the first things that come to your mind.
|
||||
|
||||
### Sorting an input that has limited range
|
||||
|
||||
[Counting sort](https://en.wikipedia.org/wiki/Counting_sort) is a non-comparison-based sort you can use on numbers where you know the range of values beforehand. Examples: [H-Index](https://leetcode.com/problems/h-index/)
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Binary Search](https://leetcode.com/problems/binary-search/)
|
||||
- [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/)
|
||||
- [Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix/)
|
||||
- [Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/)
|
||||
- [Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/)
|
||||
- [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
91
apps/website/contents/algorithms/stack.md
Normal file
91
apps/website/contents/algorithms/stack.md
Normal file
@@ -0,0 +1,91 @@
|
||||
---
|
||||
id: stack
|
||||
title: Stack cheatsheet for coding interviews
|
||||
description: Stack study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
stack coding interview study guide,
|
||||
stack tips for coding interviews,
|
||||
stack practice questions,
|
||||
stack useful techniques,
|
||||
stack time complexity,
|
||||
stack recommended study resources,
|
||||
]
|
||||
sidebar_label: Stack
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-stack.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
A stack is an abstract data type that supports the operations **push** (insert a new element on the top of the stack) and **pop** (remove and return the most recently added element, the element at the top of the stack). As an abstract data type, stacks can be implemented using arrays or singly linked lists.
|
||||
|
||||
This behavior is commonly called LIFO (last in, first out). The name "stack" for this type of structure comes from the analogy to a set of physical items stacked on top of each other.
|
||||
|
||||
Stacks are an important way of supporting nested or recursive function calls and is used to implement depth-first search. Depth-first search can be implemented using recursion or a manual stack.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [Stacks and Overflows](https://medium.com/basecs/stacks-and-overflows-dbcf7854dc67), basecs
|
||||
- Videos
|
||||
- [Stacks](https://www.coursera.org/lecture/data-structures/stacks-UdKzQ), University of California San Diego
|
||||
|
||||
## Implementations
|
||||
|
||||
| Language | API |
|
||||
| --- | --- |
|
||||
| C++ | [`std::stack`](https://docs.microsoft.com/en-us/cpp/standard-library/stack-class) |
|
||||
| Java | [`java.util.Stack`](https://docs.oracle.com/javase/10/docs/api/java/util/Stack.html) |
|
||||
| Python | Simulated using [List](https://docs.python.org/3/tutorial/datastructures.html) |
|
||||
| JavaScript | Simulated using [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) |
|
||||
|
||||
## Time complexity
|
||||
|
||||
| Operation | Big-O |
|
||||
| --------- | ----- |
|
||||
| Top/Peek | O(1) |
|
||||
| Push | O(1) |
|
||||
| Pop | O(1) |
|
||||
| isEmpty | O(1) |
|
||||
| Search | O(n) |
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty stack. Popping from an empty stack
|
||||
- Stack with one item
|
||||
- Stack with two items
|
||||
|
||||
<!-- ## Techniques
|
||||
|
||||
TODO: Monotonic stacks -->
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Valid Parentheses](https://leetcode.com/problems/valid-parentheses)
|
||||
- [Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Implement Stack using Queues](https://leetcode.com/problems/implement-queue-using-stacks)
|
||||
- [Min Stack](https://leetcode.com/problems/min-stack)
|
||||
- [Asteroid Collision](https://leetcode.com/problems/asteroid-collision)
|
||||
- [Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation)
|
||||
- [Basic Calculator](https://leetcode.com/problems/basic-calculator)
|
||||
- [Basic Calculator II](https://leetcode.com/problems/basic-calculator-ii)
|
||||
- [Daily Temperatures](https://leetcode.com/problems/daily-temperatures)
|
||||
- [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)
|
||||
- [Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
141
apps/website/contents/algorithms/string.md
Normal file
141
apps/website/contents/algorithms/string.md
Normal file
@@ -0,0 +1,141 @@
|
||||
---
|
||||
id: string
|
||||
title: String cheatsheet for coding interviews
|
||||
description: String study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
string coding interview study guide,
|
||||
string tips for coding interviews,
|
||||
string practice questions,
|
||||
string useful techniques,
|
||||
string time complexity,
|
||||
string recommended study resources,
|
||||
]
|
||||
sidebar_label: String
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-string.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
A string is a sequence of characters. Many tips that apply to arrays also apply to strings. You're recommended to read the page on [Arrays](./array.md) before reading this page.
|
||||
|
||||
Common data structures for looking up strings:
|
||||
|
||||
- [Trie/Prefix Tree](https://en.wikipedia.org/wiki/Trie)
|
||||
- [Suffix Tree](https://en.wikipedia.org/wiki/Suffix_tree)
|
||||
|
||||
Common string algorithms:
|
||||
|
||||
- [Rabin Karp](https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm) for efficient searching of substring using a rolling hash
|
||||
- [KMP](https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm) for efficient searching of substring
|
||||
|
||||
## Time complexity
|
||||
|
||||
A strings is an array of characters, so the time complexities of basic string operations will closely resemble that of array operations.
|
||||
|
||||
| Operation | Big-O |
|
||||
| --------- | ----- |
|
||||
| Access | O(1) |
|
||||
| Search | O(n) |
|
||||
| Insert | O(n) |
|
||||
| Remove | O(n) |
|
||||
|
||||
### Operations involving another string
|
||||
|
||||
Here we assume the other string is of length m.
|
||||
|
||||
| Operation | Big-O | Note |
|
||||
| --- | --- | --- |
|
||||
| Find substring | O(n.m) | This is the most naive case. There are more efficient algorithms for string searching such as the [KMP algorithm](https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm) |
|
||||
| Concatenating strings | O(n + m) | |
|
||||
| Slice | O(m) | |
|
||||
| Split (by token) | O(n + m) | |
|
||||
| Strip (remove leading and trailing whitespaces) | O(n) | |
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
Ask about input character set and case sensitivity. Usually the characters are limited to lowercase Latin characters, for example a to z.
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty string
|
||||
- String with 1 or 2 characters
|
||||
- String with repeated characters
|
||||
- Strings with only distinct characters
|
||||
|
||||
## Techniques
|
||||
|
||||
Many string questions fall into one of these buckets.
|
||||
|
||||
### Counting characters
|
||||
|
||||
Often you will need to count the frequency of characters in a string. The most common way of doing that is by using a hash table/map in your language of choice. If your language has a built-in Counter class like Python, ask if you can use that instead.
|
||||
|
||||
If you need to keep a counter of characters, a common mistake is to say that the space complexity required for the counter is O(n). The space required for a counter of a string of latin characters is O(1) not O(n). This is because the upper bound is the range of characters, which is usually a fixed constant of 26. The input set is just lowercase Latin characters.
|
||||
|
||||
#### String of unique characters
|
||||
|
||||
A neat trick to count the characters in a string of unique characters is to use a 26-bit bitmask to indicate which lower case latin characters are inside the string.
|
||||
|
||||
```py
|
||||
mask = 0
|
||||
for c in word:
|
||||
mask |= (1 << (ord(c) - ord('a')))
|
||||
```
|
||||
|
||||
To determine if two strings have common characters, perform `&` on the two bitmasks. If the result is non-zero, ie. `mask_a & mask_b > 0`, then the two strings have common characters.
|
||||
|
||||
### Anagram
|
||||
|
||||
An anagram is word switch or word play. It is the result of rearranging the letters of a word or phrase to produce a new word or phrase, while using all the original letters only once. In interviews, usually we are only bothered with words without spaces in them.
|
||||
|
||||
To determine if two strings are anagrams, there are a few approaches:
|
||||
|
||||
- Sorting both strings should produce the same resulting string. This takes O(n.log(n)) time and O(log(n)) space.
|
||||
- If we map each character to a prime number and we multiply each mapped number together, anagrams should have the same multiple (prime factor decomposition). This takes O(n) time and O(1) space. Examples: [Group Anagram](https://leetcode.com/problems/group-anagrams/)
|
||||
- Frequency counting of characters will help to determine if two strings are anagrams. This also takes O(n) time and O(1) space.
|
||||
|
||||
### Palindrome
|
||||
|
||||
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as `madam` or `racecar`.
|
||||
|
||||
Here are ways to determine if a string is a palindrome:
|
||||
|
||||
- Reverse the string and it should be equal to itself.
|
||||
- Have two pointers at the start and end of the string. Move the pointers inward till they meet. At every point in time, the characters at both pointers should match.
|
||||
|
||||
The order of characters within the string matters, so hash tables are usually not helpful.
|
||||
|
||||
When a question is about counting the number of palindromes, a common trick is to have two pointers that move outward, away from the middle. Note that palindromes can be even or odd length. For each middle pivot position, you need to check it twice - once that includes the character and once without the character. This technique is used in [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/).
|
||||
|
||||
- For substrings, you can terminate early once there is no match
|
||||
- For subsequences, use dynamic programming as there are overlapping subproblems. Check out [this question](https://leetcode.com/problems/longest-palindromic-subsequence/)
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Valid Anagram](https://leetcode.com/problems/valid-anagram)
|
||||
- [Valid Palindrome](https://leetcode.com/problems/valid-palindrome/)
|
||||
- [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement/)
|
||||
- [Find All Anagrams in a String](https://leetcode.com/problems/find-all-anagrams-in-a-string)
|
||||
- [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/description/)
|
||||
- [Group Anagrams](https://leetcode.com/problems/group-anagrams/)
|
||||
- [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/)
|
||||
- [Encode and Decode Strings (LeetCode Premium)](https://leetcode.com/problems/encode-and-decode-strings/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
103
apps/website/contents/algorithms/study-cheatsheet.md
Normal file
103
apps/website/contents/algorithms/study-cheatsheet.md
Normal file
@@ -0,0 +1,103 @@
|
||||
---
|
||||
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
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms-study-cheatsheet.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from '../\_components/InDocAd';
|
||||
|
||||
## What is this
|
||||
|
||||
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!
|
||||
|
||||
## 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 with recommended 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](./array.md) | High |
|
||||
| [String](./string.md) | High |
|
||||
| [Hash Table](./hash-table.md) | Mid |
|
||||
| [Recursion](./recursion.md) | Mid |
|
||||
| [Sorting and searching](./sorting-searching.md) | High |
|
||||
| [Matrix](./matrix.md) | High |
|
||||
| [Linked List](./linked-list.md) | Mid |
|
||||
| [Queue](./queue.md) | Mid |
|
||||
| [Stack](./stack.md) | Mid |
|
||||
| [Tree](./tree.md) | High |
|
||||
| [Graph](./graph.md) | High |
|
||||
| [Heap](./heap.md) | Mid |
|
||||
| [Trie](./trie.md) | Mid |
|
||||
| [Interval](./interval.md) | Mid |
|
||||
| [Dynamic programming](./dynamic-programming.md) | Low |
|
||||
| [Binary](./binary.md) | Low |
|
||||
| [Math](./math.md) | Low |
|
||||
| [Geometry](./geometry.md) | Low |
|
||||
|
||||
## General interview tips
|
||||
|
||||
Clarify any assumptions you made subconsciously. Many questions are under-specified on purpose.
|
||||
|
||||
Always validate input first. Check for invalid/empty/negative/different type input. Never assume you are given the valid parameters. Alternatively, clarify with the interviewer whether you can assume valid input (usually yes), which can save you time from writing code that does input validation.
|
||||
|
||||
Are there any time/space complexity requirements/constraints?
|
||||
|
||||
Check for off-by-one errors.
|
||||
|
||||
In languages where there are no automatic type coercion, check that concatenation of values are of the same type: `int`/`str`/`list`.
|
||||
|
||||
After finishing your code, use a few example inputs to test your solution.
|
||||
|
||||
Is the algorithm meant to be run multiple times, for example in a web server? If yes, the input is likely to be preprocess-able to improve the efficiency in each call.
|
||||
|
||||
Use a mix of functional and imperative programming paradigms:
|
||||
|
||||
- Write pure functions as much as possible.
|
||||
- Pure functions are easier to reason about and can help to reduce bugs in your implementation.
|
||||
- Avoid mutating the parameters passed into your function especially if they are passed by reference unless you are sure of what you are doing.
|
||||
- However, functional programming is usually expensive in terms of space complexity because of non-mutation and the repeated allocation of new objects. On the other hand, imperative code is faster because you operate on existing objects. Hence you will need to achieve a balance between accuracy vs efficiency, by using the right amount of functional and imperative code where appropriate.
|
||||
- Avoid relying on and mutating global variables. Global variables introduce state.
|
||||
- If you have to rely on global variables, make sure that you do not mutate it by accident.
|
||||
|
||||
Generally, to improve the speed of a program, we can either: (1) choose a more appropriate data structure/algorithm; or (2) use more memory. The latter demonstrates a classic space vs. time tradeoff, but it is not necessarily the case that you can only achieve better speed at the expense of space. Also, note that there is often a theoretical limit to how fast your program can run (in terms of time complexity). For instance, a question that requires you to find the smallest/largest element in an unsorted array cannot run faster than O(N).
|
||||
|
||||
Data structures are your weapons. Choosing the right weapon for the right battle is the key to victory. Be very familiar about the strengths of each data structure and the time complexities for its various operations.
|
||||
|
||||
Data structures can be augmented to achieve efficient time complexities across different operations. For example, a hash map can be used together with a doubly-linked list to achieve O(1) time complexity for both the `get` and `put` operation in an [LRU cache](https://leetcode.com/problems/lru-cache/).
|
||||
|
||||
Hash table is probably the most commonly used data structure for algorithm questions. If you are stuck on a question, your last resort can be to enumerate through the common possible data structures (thankfully there aren't that many of them) and consider whether each of them can be applied to the problem. This has worked for me sometimes.
|
||||
|
||||
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., I would write a regex to parse this string rather than using `split()` which may not cover all cases.
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
|
||||
<!-- ## References
|
||||
|
||||
- http://blog.triplebyte.com/how-to-pass-a-programming-interview
|
||||
- http://www.geeksforgeeks.org/must-do-coding-questions-for-companies-like-amazon-microsoft-adobe/
|
||||
- https://medium.com/basecs -->
|
||||
172
apps/website/contents/algorithms/tree.md
Normal file
172
apps/website/contents/algorithms/tree.md
Normal file
@@ -0,0 +1,172 @@
|
||||
---
|
||||
id: tree
|
||||
title: Tree cheatsheet for coding interviews
|
||||
description: Tree study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
tree coding interview study guide,
|
||||
tree tips for coding interviews,
|
||||
tree practice questions,
|
||||
tree useful techniques,
|
||||
tree time complexity,
|
||||
tree recommended study resources,
|
||||
]
|
||||
sidebar_label: Tree
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-tree.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
A tree is a widely used abstract data type that represents a hierarchical structure with a set of connected nodes. Each node in the tree can be connected to many children, but must be connected to exactly one parent, except for the root node, which has no parent.
|
||||
|
||||
A tree is an undirected and connected acyclic graph. There are no cycles or loops. Each node can be like the root node of its own subtree, making [recursion](recursion.md) a useful technique for tree traversal.
|
||||
|
||||
For the purpose of interviews, you will usually be asked on binary trees as opposed to ternary (3 children) or N-ary (N children) trees. In this page,we will cover binary trees and binary search trees, which is a special case of binary trees.
|
||||
|
||||
Trees are commonly used to represent hierarchical data, e.g. file systems, JSON, and HTML documents. Do check out the section on [Trie](trie.md), which is an advanced tree used for efficiently storing and searching strings.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Videos
|
||||
- [Trees](https://www.coursera.org/lecture/data-structures/trees-95qda), University of California San Diego
|
||||
- Readings
|
||||
- [How To Not Be Stumped By Trees](https://medium.com/basecs/how-to-not-be-stumped-by-trees-5f36208f68a7), basecs
|
||||
- [Leaf It Up To Binary Trees](https://medium.com/basecs/leaf-it-up-to-binary-trees-11001aaf746d), basecs
|
||||
- Additional (only if you have time)
|
||||
- [The Little AVL Tree That Could](https://medium.com/basecs/the-little-avl-tree-that-could-86a3cae410c7), basecs
|
||||
- [Busying Oneself With B-Trees](https://medium.com/basecs/busying-oneself-with-b-trees-78bbf10522e7), basecs
|
||||
- [Painting Nodes Black With Red-Black Trees](https://medium.com/basecs/painting-nodes-black-with-red-black-trees-60eacb2be9a5), basecs
|
||||
|
||||
## Common terms you need to know
|
||||
|
||||
- **Neighbor** - Parent or child of a node
|
||||
- **Ancestor** - A node reachable by traversing its parent chain
|
||||
- **Descendant** - A node in the node's subtree
|
||||
- **Degree** - Number of children of a node
|
||||
- **Degree** of a tree - Maximum degree of nodes in the tree
|
||||
- **Distance** - Number of edges along the shortest path between two nodes
|
||||
- **Level/Depth** - Number of edges along the unique path between a node and the root node
|
||||
- **Width** - Number of nodes in a level
|
||||
|
||||
### Binary tree
|
||||
|
||||
Binary means two, so nodes in a binary trees have a maximum of two children.
|
||||
|
||||
**Binary tree terms**
|
||||
|
||||
- Complete binary tree - A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible.
|
||||
- Balanced binary tree - A binary tree structure in which the left and right subtrees of every node differ in height by no more than 1.
|
||||
|
||||
**Traversals**
|
||||
|
||||

|
||||
|
||||
Given such a tree, these are the results for the various traversals.
|
||||
|
||||
- **In-order traversal** - Left -> Root -> Right
|
||||
- Result: 2, 7, 5, 6, 11, 1, 9, 5, 9
|
||||
- **Pre-order traversal** - Root -> Left -> Right
|
||||
- Result: 1, 7, 2, 6, 5, 11, 9, 9, 5
|
||||
- **Post-order traversal** - Left -> Right -> Root
|
||||
- Result: 2, 5, 11, 6, 7, 5, 9, 9, 1
|
||||
|
||||
Note that in-order traversal of a binary tree is insufficient to uniquely serialize a tree. Pre-order or post-order traversal is also required.
|
||||
|
||||
### Binary search tree (BST)
|
||||
|
||||
In-order traversal of a BST will give you all elements in order.
|
||||
|
||||
Be very familiar with the properties of a BST and validating that a binary tree is a BST. This comes up more often than expected.
|
||||
|
||||
When a question involves a BST, the interviewer is usually looking for a solution which runs faster than O(n).
|
||||
|
||||
#### Time complexity
|
||||
|
||||
| Operation | Big-O |
|
||||
| --------- | --------- |
|
||||
| Access | O(log(n)) |
|
||||
| Search | O(log(n)) |
|
||||
| Insert | O(log(n)) |
|
||||
| Remove | O(log(n)) |
|
||||
|
||||
Space complexity of traversing balanced trees is O(h) where h is the height of the tree, while traversing very skewed trees (which is essentially a linked list) will be O(n).
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
You should be very familiar with writing pre-order, in-order, and post-order traversal recursively. As an extension, challenge yourself by writing them iteratively. Sometimes interviewers ask candidates for the iterative approach, especially if the candidate finishes writing the recursive approach too quickly.
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Empty tree
|
||||
- Single node
|
||||
- Two nodes
|
||||
- Very skewed tree (like a linked list)
|
||||
|
||||
## Common routines
|
||||
|
||||
Be familiar with the following routines because many tree questions make use of one or more of these routines in the solution:
|
||||
|
||||
- Insert value
|
||||
- Delete value
|
||||
- Count number of nodes in tree
|
||||
- Whether a value is in the tree
|
||||
- Calculate height of the tree
|
||||
- Binary search tree
|
||||
- Determine if is binary search tree
|
||||
- Get maximum value
|
||||
- Get minimum value
|
||||
|
||||
## Techniques
|
||||
|
||||
### Use recursion
|
||||
|
||||
Recursion is the most common approach for traversing trees. When you notice that the subtree problem can be used to solve the entire problem, try using recursion.
|
||||
|
||||
When using recursion, always remember to check for the base case, usually where the node is `null`.
|
||||
|
||||
Sometimes it is possible that your recursive function needs to return two values.
|
||||
|
||||
### Traversing by level
|
||||
|
||||
When you are asked to traverse a tree by level, use breadth-first search.
|
||||
|
||||
### Summation of nodes
|
||||
|
||||
If the question involves summation of nodes along the way, be sure to check whether nodes can be negative.
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- Binary Tree
|
||||
- [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)
|
||||
- [Invert/Flip Binary Tree](https://leetcode.com/problems/invert-binary-tree/)
|
||||
- Binary Search Tree
|
||||
- [Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- Binary tree
|
||||
- [Same Tree](https://leetcode.com/problems/same-tree/)
|
||||
- [Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum/)
|
||||
- [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)
|
||||
- [Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/)
|
||||
- [Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view/)
|
||||
- [Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree/)
|
||||
- [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)
|
||||
- [Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree/)
|
||||
- Binary search tree
|
||||
- [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/)
|
||||
- [Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
73
apps/website/contents/algorithms/trie.md
Normal file
73
apps/website/contents/algorithms/trie.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: trie
|
||||
title: Trie cheatsheet for coding interviews
|
||||
description: Trie study guide for coding interviews, including practice questions, techniques, time complexity, and recommended resources
|
||||
keywords:
|
||||
[
|
||||
trie coding interview study guide,
|
||||
trie tips for coding interviews,
|
||||
trie practice questions,
|
||||
trie useful techniques,
|
||||
trie time complexity,
|
||||
trie recommended study resources,
|
||||
]
|
||||
sidebar_label: Trie
|
||||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/algorithms/algorithms/algorithms-trie.png" />
|
||||
</head>
|
||||
|
||||
## Introduction
|
||||
|
||||
Tries are special trees (prefix trees) that make searching and storing strings more efficient. Tries have many practical applications, such as conducting searches and providing autocomplete. It is helpful to know these common applications so that you can easily identify when a problem can be efficiently solved using a trie.
|
||||
|
||||
Be familiar with implementing from scratch, a `Trie` class and its `add`, `remove` and `search` methods.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [Trying to Understand Tries](https://medium.com/basecs/trying-to-understand-tries-3ec6bede0014), basecs
|
||||
- [Implement Trie (Prefix Tree)](https://leetcode.com/articles/implement-trie-prefix-tree/), LeetCode
|
||||
- Additional (only if you have time)
|
||||
- [Compressing Radix Trees Without (Too Many) Tears](https://medium.com/basecs/compressing-radix-trees-without-too-many-tears-a2e658adb9a0), basecs
|
||||
|
||||
## Time complexity
|
||||
|
||||
`m` is the length of the string used in the operation.
|
||||
|
||||
| Operation | Big-O | Note |
|
||||
| --------- | ----- | ---- |
|
||||
| Search | O(m) | |
|
||||
| Insert | O(m) | |
|
||||
| Remove | O(m) | |
|
||||
|
||||
## Corner cases
|
||||
|
||||
- Searching for a string in an empty trie
|
||||
- Inserting empty strings into a trie
|
||||
|
||||
## Techniques
|
||||
|
||||
Sometimes preprocessing a dictionary of words (given in a list) into a trie, will improve the efficiency of searching for a word of length k, among n words. Searching becomes O(k) instead of O(n).
|
||||
|
||||
## Essential questions
|
||||
|
||||
_These are essential questions to practice if you're studying for this topic._
|
||||
|
||||
- [Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-prefix-tree)
|
||||
|
||||
## Recommended practice questions
|
||||
|
||||
_These are recommended questions to practice after you have studied for the topic and have practiced the essential questions._
|
||||
|
||||
- [Add and Search Word](https://leetcode.com/problems/add-and-search-word-data-structure-design)
|
||||
- [Word Break](https://leetcode.com/problems/word-break)
|
||||
- [Word Search II](https://leetcode.com/problems/word-search-ii/)
|
||||
|
||||
## Recommended courses
|
||||
|
||||
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
207
apps/website/contents/behavioral-interview-questions.md
Normal file
207
apps/website/contents/behavioral-interview-questions.md
Normal file
@@ -0,0 +1,207 @@
|
||||
---
|
||||
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: Common behavioral questions to practice
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/behavioral-interview-questions.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
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)
|
||||
110
apps/website/contents/behavioral-interview.md
Normal file
110
apps/website/contents/behavioral-interview.md
Normal file
@@ -0,0 +1,110 @@
|
||||
---
|
||||
id: behavioral-interview
|
||||
title: 'Behavioral interviews for Software Engineers: How to prepare'
|
||||
description: How to prepare for Software Engineer behavioral interviews
|
||||
keywords:
|
||||
[
|
||||
software engineer behavioral interview prep,
|
||||
software developer behavioral interview prep,
|
||||
behavioral interview software engineer,
|
||||
how to prepare for behavioral interview software engineer,
|
||||
google behavioral interview,
|
||||
facebook behavioral interview,
|
||||
amazon behavioral interview,
|
||||
microsoft behavioral interview,
|
||||
]
|
||||
sidebar_label: Step-by-step how to prepare
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/behavioral-interview.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
## What are behavioral interviews
|
||||
|
||||
Succeeding in an engineering career involves more than just technical skills. People skills become more important as an engineer becomes more senior. Senior engineers should have the ability to lead and influence, resolve conflicts, anticipate risks, plan the roadmap, and more.
|
||||
|
||||
Hiring a talented engineer that cannot work with others can ultimately be a net deficit for companies. Companies don't want to hire [brilliant jerks](http://www.brendangregg.com/blog/2017-11-13/brilliant-jerks.html). The company is better off not hiring a very talented engineer who refuses to work with others or causes an entire team to be unproductive. Companies want to hire the right person that will work well with the existing employees and help the team and company achieve greater heights, and behavioral interviews are one way of determining if someone will be good to work with from a non-technical standpoint.
|
||||
|
||||
Typically, behavioral interview questions can be split into several types:
|
||||
|
||||
1. Getting to know your career preferences, ambitions and plans
|
||||
1. Discuss details of experiences or projects written in your resume
|
||||
1. "Tell me about a time where you" type of questions where you describe how you demonstrated certain traits or responded to a situation
|
||||
|
||||
## The importance of behavioral interviews
|
||||
|
||||
Companies value behavioral skills and do evaluate candidates on them. At the time of writing, Facebook has one round (out of four) dedicated to behavioral interviews. Airbnb has TWO rounds (out of six) dedicated to behavioral interviews/company fit. Lyft has one round (out of five) dedicated to past experience and situational questions by a hiring manager.
|
||||
|
||||
## How are behavioral interviews evaluated
|
||||
|
||||
Unlike technical interviews, behavioral interviews have a lot more variance in terms of evaluation criteria. However, most top tech companies use their company values to evaluate candidates. Interviewers typically have to fill in a section evaluating how a candidate has displayed behaviors in line with company values. It is for this reason that you should search up a company's culture and values and ensure that you embody them within your answers. You'd also find it useful to speak with one of your connections currently working at the company you are applying for to find out more about which values are typically valued in the team.
|
||||
|
||||
Some examples of common values evaluated are:
|
||||
|
||||
- **Empathy** - Puts themselves in the shoes of others and tries to understand others' reasoning
|
||||
- **Proactivity and willingness to wear multiple hats** - Steps up when the situation requires it
|
||||
- **Project management** - Able to orchestrate multiple work streams to meet timelines and unblock tasks
|
||||
- **Conflict management** - Able to manage conflict between themselves and or between other parties, by explaining and ensuring no hard feelings remain
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## How to prepare for behavioral interviews
|
||||
|
||||
1. Learn the STAR answer format
|
||||
1. Prepare your answers to commonly asked questions
|
||||
1. Prepare experiences to showcase fit to the company's culture / core values
|
||||
1. Try out mock behavioral interviews
|
||||
1. Use structured courses
|
||||
|
||||
### 1. Learn the STAR answer format
|
||||
|
||||
The [STAR](https://en.wikipedia.org/wiki/Situation,_task,_action,_result) format is a framework to help you organize answers to behavioral questions - especially ones requiring you to discuss previous experiences
|
||||
|
||||
- **Situation** - The interviewer wants you to present a recent challenge and situation which you found yourself in
|
||||
- **Task** - What were you required to achieve? The interviewer will be looking to see what you were trying to achieve from the situation. Some performance development methods use "Target" rather than "Task". Job interview candidates who describe a "Target" they set themselves instead of an externally imposed "Task" emphasize their own intrinsic motivation to perform and to develop their performance
|
||||
- **Action** - What did you do? The interviewer will be looking for information on what you did, why you did it, and what the alternatives were
|
||||
- **Results** - What was the outcome of your actions? What did you achieve through your actions and what did you learn? What steps did you take to improve after the experience?
|
||||
|
||||
#### Example of how to apply STAR to a behavioral interview question
|
||||
|
||||
Here's an example of how the STAR format can be used to answer the question: "Tell me about a time in which you had a conflict and needed to influence somebody else".
|
||||
|
||||
#### Situation
|
||||
|
||||
> "I was the team lead of a school project about building a social network mobile web app. Our designer's midterms were approaching and didn't have time to produce the mockups. Our front-end person was rushing him for the mockups so that he could proceed with his work, and that was stressing the designer out. The atmosphere in the team was tense."
|
||||
|
||||
#### Task
|
||||
|
||||
> "As the team lead, I had to resolve the tension between the front-end developer and the designer so that the team could work together peacefully and complete the project on time."
|
||||
|
||||
#### Action
|
||||
|
||||
> "I spoke to the front-end developer to ask him why he was rushing the designer for the designs. He said that he wanted the designs early because it would be a waste of time rebuilding if the designer designed something different eventually. I explained to him that the midterm dates were out of the designer's control and we had to be more understanding about each other's schedules. I spoke to the designer to get a rough idea of what he had in mind and asked him when he could commit to producing the high-fidelity designs. He replied that he could start on them as soon as his midterms were over. I explained to him why the front-end developer was pushing him for the mockups, and that the front-end developer had no ill intentions and simply wanted the project to succeed. As someone with some experience in UI/UX design, I came up with wireframe mocks, ran them by the designer for approval, then passed them to the front-end developer to start building. I encouraged the front-end developer to use placeholders and not be too concerned about the details for now. We could build the non-UI parts first (authentication, hook up with APIs) and tweak pixels and add polish later on. The front-end developer agreed and went ahead with the approach. I explained to the front-end developer that the designer will pass us the mockups after his midterm, by <DATE>."
|
||||
|
||||
#### Result
|
||||
|
||||
> "When our designer ended midterms, he came back with beautiful mockups that fit well into the wireframes. Our front-end developer implemented them with great care to detail. We ended up scoring top marks for the project and became a great team."
|
||||
|
||||
### 2. Prepare your answers to commonly asked questions
|
||||
|
||||
The next natural step is to start preparing your answers for commonly asked behavioral interview questions. You may refer to [my list of 30 questions](./behavioral-interview-questions.md) which were collated across top tech companies for this.
|
||||
|
||||
While most people might be inclined towards memorization, it's much better to pen down bullet points to each question and practice verbalizing them near to the interviews, so that your answers will come out more naturally.
|
||||
|
||||
### 3. Prepare experiences to showcase fit to the company's culture / core values
|
||||
|
||||
As aforementioned, most top tech companies use their company values to evaluate candidates in behavioral interviews. As such, you should do your research to find out what those values are and ensure you have prepared experiences that showcase fit.
|
||||
|
||||
### 4. Try out mock behavioral interviews
|
||||
|
||||
If you would like to practice behavioral interviews with professional interviewers from top tech companies, schedule one with [interviewing.io](https://iio.sh/r/DMCa). Interviewing.io boasts a large pool of interviewers from Facebook, Amazon, Apply, Google and Microsoft. I have used [interviewing.io](https://iio.sh/r/DMCa) both as an interviewer and interviewee and can guarantee a good experience with this platform.
|
||||
|
||||
### 5. Use structured courses
|
||||
|
||||
I don't really think one needs to attend a course on behavioral interviews, but your mileage may vary. I've seen candidates get rejected for failing the behavioral round even though they did super well on the coding and system design interviews. If you want to take a course on behavioral interviews, I'd recommend the following courses:
|
||||
|
||||
- ["Behavioral Interviews" by Exponent](https://www.tryexponent.com/courses/behavioral?ref=techinterviewhandbook) - While Exponent also has courses on technical content, what really makes them stand out from the other interview preparation platform is their availability of content for non-software engineering roles such as Product Management and Product Marketing. Their behavioral interview course is a mix of videos (by the Exponent CEO himself!) and text, going through the most common questions and imparting you with techniques to help you ace the interview. To top it off, they also have an interview question bank for behavioral questions with responses from the platform's helpful community. While the subscription might be a little pricey for just the behavioral interviews content, they also offer quality technical content for [System Design](https://www.tryexponent.com/courses/system-design-interview?ref=techinterviewhandbook), [Data Structures](https://www.tryexponent.com/courses/swe-practice?ref=techinterviewhandbook) and [Algorithms](https://www.tryexponent.com/courses/algorithms?ref=techinterviewhandbook). The convenience of a one-stop platform which covers all aspects of technical interview preparation is very enticing.
|
||||
- ["Grokking the Behavioral Interview" on Educative](https://www.educative.io/courses/grokking-the-behavioral-interview?aff=x23W) - As per other courses on Educative, this course is text-based and they believe that text-based courses are the more efficient than video courses. One thing that stands out about this course is that they teach you **patterns** for behavioral interviews, not just about memorizing questions and preparing answers.
|
||||
45
apps/website/contents/best-coding-interview-courses.md
Normal file
45
apps/website/contents/best-coding-interview-courses.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
id: best-coding-interview-courses
|
||||
title: Best coding interview courses
|
||||
description: Best courses to take to prepare for your coding interviews
|
||||
sidebar_label: 🔥 Best interview courses
|
||||
keywords: [algorithm, coding, interview, questions]
|
||||
---
|
||||
|
||||
If you prefer courses where the learning is more structured, here are a few recommendations. **In no way is taking online courses a must in order to pass interviews.**
|
||||
|
||||
## General
|
||||
|
||||
import AlgorithmCourses from './\_courses/AlgorithmCourses.md'
|
||||
|
||||
<AlgorithmCourses />
|
||||
|
||||
## Python
|
||||
|
||||
| Course | Reviews | Duration | Price | Contents |
|
||||
| :-- | --- | --- | --- | --- |
|
||||
| [Ace the Python Coding Interview](https://www.educative.io/path/ace-python-coding-interview?aff=x23W) | 4.6/5 | 93h | $ | Basic data structures and algorithms + practice. Also includes **system design** and concurrency |
|
||||
| [The Complete Data Structures and Algorithms Course in Python](https://fxo.co/DQpc) | 4.6/5 | 41h | $ | Basic data structures and algorithms |
|
||||
| [Python for Data Structures, Algorithms, and Interviews!](https://fxo.co/DQpb) | 4.5/5 | 16.5h | $$ | Basic data structures and algorithms, job application, behavioral interview, negotiation |
|
||||
|
||||
## Java
|
||||
|
||||
| Course | Reviews | Duration | Price | Contents |
|
||||
| :-- | --- | --- | --- | --- |
|
||||
| [Ace the Java Coding Interview](https://www.educative.io/path/ace-java-coding-interview?aff=x23W) | 4.6/5 | 55h | $ | Basic data structures and algorithms + practice. Also includes **system design** |
|
||||
| [Java Data Structures and Algorithms Masterclass](https://fxo.co/DQpa) | 4.5/5 | 45h | $ | Basic and advanced data structures and algorithms |
|
||||
| [Data Structures and Algorithms: Deep Dive Using Java](https://fxo.co/DQpW) | 4.5/5 | 16h | $$ | Basic data structures and algorithms |
|
||||
|
||||
## JavaScript
|
||||
|
||||
| Course | Reviews | Duration | Price | Contents |
|
||||
| :-- | --- | --- | --- | --- |
|
||||
| [Ace the JavaScript Coding Interview](https://www.educative.io/path/ace-javascript-coding-interview?aff=x23W) | 4.7/5 | 87h | $ | Basic data structures and algorithms + practice. Also includes **system design** |
|
||||
| [JavaScript Data Structures and Algorithms Masterclass](https://fxo.co/DQpZ) | 4.5/5 | 45h | $ | Basic and advanced data structures and algorithms |
|
||||
| [Master the Coding Interview: Data Structures + Algorithms](https://fxo.co/DQpY) | 4.6/5 | 19.5h | $$ | Basic data structures and algorithms, job application, behavioral interview, negotiation |
|
||||
|
||||
## C++
|
||||
|
||||
| Course | Reviews | Duration | Price | Contents |
|
||||
| :-- | --- | --- | --- | --- |
|
||||
| [Ace the C++ Coding Interview](https://www.educative.io/path/ace-cpp-coding-interview?aff=x23W) | 4.6/5 | 60h | $ | Basic data structures and algorithms + practice. Also includes **system design**, concurrency and behavioral contents |
|
||||
171
apps/website/contents/best-practice-questions.md
Normal file
171
apps/website/contents/best-practice-questions.md
Normal file
@@ -0,0 +1,171 @@
|
||||
---
|
||||
id: best-practice-questions
|
||||
title: Best practice questions
|
||||
sidebar_label: 🔥 Best practice questions
|
||||
description: The best practice questions to prepare for algorithmic coding interviews by the author of Blind 75 spread across a 5-week schedule
|
||||
keywords: [algorithm, coding, interview, questions, leetcode, blind 75]
|
||||
displayed_sidebar: docs
|
||||
pagination_next: coding-interview-cheatsheet
|
||||
---
|
||||
|
||||
import AlgorithmCourses from './\_courses/AlgorithmCourses.md'
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
<head>
|
||||
<title>Best practice questions by the author of Blind 75 | Tech Interview Handbook</title>
|
||||
<meta property="og:title" content="Best practice questions by the author of Blind 75 | Tech Interview Handbook"/>
|
||||
</head>
|
||||
|
||||
:::tip
|
||||
|
||||
As of April 2022, I've developed a [12-week study plan](./coding-interview-study-plan.md) which includes a curriculum for revision and practice questions. If you want to customize your own practice questions, I've also developed [Grind 75](https://www.techinterviewhandbook.org/grind75) which is a modern version of Blind 75 that you can customize.
|
||||
|
||||
:::
|
||||
|
||||
Hey there, the author of Blind 75 here 👋!
|
||||
|
||||
Practicing is the best way to prepare for coding interviews. LeetCode has over a thousand questions. Which should you practice? Hence years ago, I curated a list of the most important 75 questions on [LeetCode](https://leetcode.com). Many other LeetCode questions are a mash of the techniques from these individual questions. I used this list in my last job hunt to only do the important questions.
|
||||
|
||||
I [shared this list on Blind](https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-100-LeetCode-Questions-to-Save-Your-Time-OaM1orEU) by extracting the questions from [my freeCodeCamp article](https://www.freecodecamp.org/news/coding-interviews-for-dummies-5e048933b82b/) to save peoples' time when revising and someone reposted this list on [the LeetCode forum](https://leetcode.com/discuss/general-discussion/460599/blind-75-leetcode-questions). It somehow blew up and became super famous in the coding interview scene, people even gave it a name - **Blind 75**. The Blind 75 questions as a LeetCode list can be found [here](https://leetcode.com/list/xi4ci4ig/).
|
||||
|
||||
Years later, I further distilled the list down into only 50 questions and spread them across a 5-week schedule. Here is the suggested schedule for revising and practicing algorithm questions on LeetCode. Sign up for an account if you don't already have one, it's critical to your success in interviewing!
|
||||
|
||||
When practicing, you are advised to treat it like a real coding interview and check through thoroughly before submitting. Consider even manually coming up with some test cases and running through them to verify correctness!
|
||||
|
||||
I've created a [LeetCode list](https://leetcode.com/list/9h4lgwl2) for the following questions (except the Premium ones). Feel free to use it to track your practice progress.
|
||||
|
||||
:::tip Expert tip
|
||||
|
||||
If you're running low on time, [AlgoMonster](https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=) aims to help you ace the technical interview **in the shortest time possible**. By Google engineers, [AlgoMonster](https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=) uses a data-driven approach to teach you most useful key question patterns and has contents to help you quickly revise basic data structures and algorithms. **Learn and understand patterns, not memorize answers!**
|
||||
|
||||
:::
|
||||
|
||||
## Week 1 - Sequences
|
||||
|
||||
In week 1, we will warm up by doing a mix of easy and medium questions on arrays and strings. Arrays and strings are the most common types of questions to be found in interviews; gaining familiarity with them will help in building strong fundamentals to better handle tougher questions.
|
||||
|
||||
| Question | Difficulty | LeetCode |
|
||||
| :-- | --- | --- |
|
||||
| Two Sum | Easy | [Link](https://leetcode.com/problems/two-sum/) |
|
||||
| Contains Duplicate | Easy | [Link](https://leetcode.com/problems/contains-duplicate/) |
|
||||
| Best Time to Buy and Sell Stock | Easy | [Link](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/) |
|
||||
| Valid Anagram | Easy | [Link](https://leetcode.com/problems/valid-anagram/) |
|
||||
| Valid Parentheses | Easy | [Link](https://leetcode.com/problems/valid-parentheses/) |
|
||||
| Maximum Subarray | Easy | [Link](https://leetcode.com/problems/maximum-subarray/) |
|
||||
| Product of Array Except Self | Medium | [Link](https://leetcode.com/problems/product-of-array-except-self/) |
|
||||
| 3Sum | Medium | [Link](https://leetcode.com/problems/3sum/) |
|
||||
| Merge Intervals | Medium | [Link](https://leetcode.com/problems/merge-intervals/) |
|
||||
| Group Anagrams | Medium | [Link](https://leetcode.com/problems/group-anagrams/) |
|
||||
|
||||
#### Optional
|
||||
|
||||
| Question | Difficulty | LeetCode |
|
||||
| :-- | --- | --- |
|
||||
| Maximum Product Subarray | Medium | [Link](https://leetcode.com/problems/maximum-product-subarray/) |
|
||||
| Search in Rotated Sorted Array | Medium | [Link](https://leetcode.com/problems/search-in-rotated-sorted-array/) |
|
||||
|
||||
## Week 2 - Data structures
|
||||
|
||||
The focus of week 2 is on linked lists, strings and matrix-based questions. The goal is to learn the common routines dealing with linked lists, traversing matrices and sequence analysis (arrays/strings) techniques such as sliding window, linked list traversal and matrix traversal.
|
||||
|
||||
| Question | Difficulty | LeetCode |
|
||||
| :-- | --- | --- |
|
||||
| Reverse a Linked List | Easy | [Link](https://leetcode.com/problems/reverse-linked-list/) |
|
||||
| Detect Cycle in a Linked List | Easy | [Link](https://leetcode.com/problems/linked-list-cycle/) |
|
||||
| Container With Most Water | Medium | [Link](https://leetcode.com/problems/container-with-most-water/) |
|
||||
| Find Minimum in Rotated Sorted Array | Medium | [Link](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/) |
|
||||
| Longest Repeating Character Replacement | Medium | [Link](https://leetcode.com/problems/longest-repeating-character-replacement/) |
|
||||
| Longest Substring Without Repeating Characters | Medium | [Link](https://leetcode.com/problems/longest-substring-without-repeating-characters/) |
|
||||
| Number of Islands | Medium | [Link](https://leetcode.com/problems/number-of-islands/) |
|
||||
| Remove Nth Node From End Of List | Medium | [Link](https://leetcode.com/problems/remove-nth-node-from-end-of-list/) |
|
||||
| Palindromic Substrings | Medium | [Link](https://leetcode.com/problems/palindromic-substrings/) |
|
||||
| Pacific Atlantic Water Flow | Medium | [Link](https://leetcode.com/problems/pacific-atlantic-water-flow/) |
|
||||
| Minimum Window Substring | Hard | [Link](https://leetcode.com/problems/minimum-window-substring/) |
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Week 3 - Non-linear data structures
|
||||
|
||||
The focus of week 3 is on non-linear data structures like trees, graphs and heaps. You should be familiar with the various tree traversal (in-order, pre-order, post-order) algorithms and graph traversal algorithms such as breadth-first search and depth-first search. In my experience, using more advanced graph algorithms (Dijkstra's and Floyd-Warshall) is quite rare and usually not necessary.
|
||||
|
||||
| Question | Difficulty | LeetCode |
|
||||
| :-- | --- | --- |
|
||||
| Invert/Flip Binary Tree | Easy | [Link](https://leetcode.com/problems/invert-binary-tree/) |
|
||||
| Validate Binary Search Tree | Medium | [Link](https://leetcode.com/problems/validate-binary-search-tree/) |
|
||||
| Non-overlapping Intervals | Medium | [Link](https://leetcode.com/problems/non-overlapping-intervals/) |
|
||||
| Construct Binary Tree from Preorder and Inorder Traversal | Medium | [Link](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) |
|
||||
| Top K Frequent Elements | Medium | [Link](https://leetcode.com/problems/top-k-frequent-elements/) |
|
||||
| Clone Graph | Medium | [Link](https://leetcode.com/problems/clone-graph/) |
|
||||
| Course Schedule | Medium | [Link](https://leetcode.com/problems/course-schedule/) |
|
||||
| Serialize and Deserialize Binary Tree | Hard | [Link](https://leetcode.com/problems/serialize-and-deserialize-binary-tree/) |
|
||||
| Binary Tree Maximum Path Sum | Hard | [Link](https://leetcode.com/problems/binary-tree-maximum-path-sum/) |
|
||||
|
||||
#### Optional
|
||||
|
||||
| Question | Difficulty | LeetCode |
|
||||
| :-- | --- | --- |
|
||||
| Maximum Depth of Binary Tree | Easy | [Link](https://leetcode.com/problems/maximum-depth-of-binary-tree/) |
|
||||
| Same Tree | Easy | [Link](https://leetcode.com/problems/same-tree/) |
|
||||
| Binary Tree Level Order Traversal | Medium | [Link](https://leetcode.com/problems/binary-tree-level-order-traversal/) |
|
||||
| Encode and Decode Strings | Medium | [Link](https://leetcode.com/problems/encode-and-decode-strings/) (Premium) |
|
||||
|
||||
## Week 4 - More data structures
|
||||
|
||||
Week 4 builds up on knowledge from previous weeks but questions are of increased difficulty. Expect to see such level of questions during interviews. You get more practice on more advanced data structures such as (but not exclusively limited to) heaps and tries which are less common but are still asked.
|
||||
|
||||
| Question | Difficulty | LeetCode |
|
||||
| :-- | --- | --- |
|
||||
| Subtree of Another Tree | Easy | [Link](https://leetcode.com/problems/subtree-of-another-tree/) |
|
||||
| Lowest Common Ancestor of BST | Easy | [Link](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/) |
|
||||
| Implement Trie (Prefix Tree) | Medium | [Link](https://leetcode.com/problems/implement-trie-prefix-tree/) |
|
||||
| Add and Search Word | Medium | [Link](https://leetcode.com/problems/add-and-search-word-data-structure-design/) |
|
||||
| Kth Smallest Element in a BST | Medium | [Link](https://leetcode.com/problems/kth-smallest-element-in-a-bst/) |
|
||||
| Merge K Sorted Lists | Hard | [Link](https://leetcode.com/problems/merge-k-sorted-lists/) |
|
||||
| Find Median from Data Stream | Hard | [Link](https://leetcode.com/problems/find-median-from-data-stream/) |
|
||||
| Insert Interval | Medium | [Link](https://leetcode.com/problems/insert-interval/) |
|
||||
| Longest Consecutive Sequence | Medium | [Link](https://leetcode.com/problems/longest-consecutive-sequence/) |
|
||||
| Word Search II | Hard | [Link](https://leetcode.com/problems/word-search-ii/) |
|
||||
|
||||
#### Optional
|
||||
|
||||
| Question | Difficulty | LeetCode |
|
||||
| :-- | --- | --- |
|
||||
| Meeting Rooms | Easy | [Link](https://leetcode.com/problems/meeting-rooms/) (Premium) |
|
||||
| Meeting Rooms II | Medium | [Link](https://leetcode.com/problems/meeting-rooms-ii/) (Premium) |
|
||||
| Graph Valid Tree | Medium | [Link](https://leetcode.com/problems/graph-valid-tree/) (Premium) |
|
||||
| Number of Connected Components in an Undirected Graph | Medium | [Link](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/) (Premium) |
|
||||
| Alien Dictionary | Hard | [Link](https://leetcode.com/problems/alien-dictionary/) (Premium) |
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Week 5 - Dynamic programming
|
||||
|
||||
Week 5 focuses on Dynamic Programming (DP) questions. Personally as an interviewer, I'm not a fan of DP questions as they are not really applicable to practical scenarios and frankly if I were made to do the tough DP questions during my interviews I'd not have gotten the job. However, companies like Google still ask DP questions and if joining Google is your dream, DP is unavoidable.
|
||||
|
||||
DP questions can be hard to master and the best way to get better at them is... you guessed it - practice! Be familiar with the concepts of memoization and backtracking.
|
||||
|
||||
Practically speaking the return of investment (ROI) on studying and practicing for DP questions is very low. Hence DP questions are less important/optional and you should only do them if you have time to spare and you're very keen to have all bases covered (and interviewing with Google).
|
||||
|
||||
| Question | Difficulty | LeetCode |
|
||||
| :-- | --- | --- |
|
||||
| Climbing Stairs | Easy | [Link](https://leetcode.com/problems/climbing-stairs/) |
|
||||
| Coin Change | Medium | [Link](https://leetcode.com/problems/coin-change/) |
|
||||
| Longest Increasing Subsequence | Medium | [Link](https://leetcode.com/problems/longest-increasing-subsequence/) |
|
||||
| Combination Sum | Medium | [Link](https://leetcode.com/problems/combination-sum-iv/) |
|
||||
| House Robber | Medium | [Link](https://leetcode.com/problems/house-robber/) |
|
||||
| House Robber II | Medium | [Link](https://leetcode.com/problems/house-robber-ii/) |
|
||||
| Decode Ways | Medium | [Link](https://leetcode.com/problems/decode-ways/) |
|
||||
| Unique Paths | Medium | [Link](https://leetcode.com/problems/unique-paths/) |
|
||||
| Jump Game | Medium | [Link](https://leetcode.com/problems/jump-game/) |
|
||||
| Word Break | Medium | [Link](https://leetcode.com/problems/word-break/) |
|
||||
|
||||
#### Dynamic programming course
|
||||
|
||||
- [Grokking the Dynamic Programming Patterns for Coding Interviews](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-dynamic-programming)
|
||||
|
||||
## Quality courses
|
||||
|
||||
If you want more structured algorithms practice, I recommend the following courses:
|
||||
|
||||
<AlgorithmCourses />
|
||||
93
apps/website/contents/choosing-between-companies.md
Normal file
93
apps/website/contents/choosing-between-companies.md
Normal file
@@ -0,0 +1,93 @@
|
||||
---
|
||||
id: choosing-between-companies
|
||||
title: Choosing between companies
|
||||
---
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
If you have passed the interviews and received multiple offers, congratulations on the feat! Now you are faced with yet another problem (albeit a good one!) of choosing between companies. Here we will provide some insights into the factors you should be considering when deciding on the company to join. Every individual is different and certain factors matter more/less to others, so only you can decide what is best for you.
|
||||
|
||||
Do your due diligence by researching on the companies before deciding!
|
||||
|
||||
## Compensation
|
||||
|
||||
First and foremost, compensation. Most technical roles at tech companies would receive compensation in similar components - Base salary, Bonuses, Stocks, and Sign On. The [Understanding Compensation](./understanding-compensation.md) section goes into more detail. Some companies are more flexible in their offer and allow candidates to choose between higher base salary or higher stocks. Base salary is the most straightforward to understand and you are being paid that same amount regardless of how well/poorly the company is doing. Bonuses are also usually a percentage of the base salary, so a high base salary is great for the risk-adverse.
|
||||
|
||||
Not all stock grants are equal as well. Some companies have linear vesting cycles (you vest the same amount every year), some companies like Amazon and Snap have backloaded schemes (you vest less in the earlier years, more later), and there are pay attention to cliffs as well. [Stripe and Lyft](https://www.theinformation.com/articles/stripe-and-lyft-speed-up-equity-payouts-to-first-year) recently changed their stock structure and announced that they will speed up equity payouts to the first year. This sounds good initially, [but in reality there are some nuances](https://tanay.substack.com/p/employee-compensation-and-one-year).
|
||||
|
||||
Regardless of company, **always negotiate** your offer, especially if you have multiple offers to choose from! Having multiple offers in hand is the best bargaining chip you can have for negotiation and you should leverage it. We go into this more in the [Negotiation](./negotiation.md) section. Use [Moonchaser](https://www.moonchaser.io/?utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_choosing_between_companies) for risk-free negotiation services.
|
||||
|
||||
## Products
|
||||
|
||||
What does the company work on and is the company working on a domain you are interested in? Most big tech companies have teams working on all sorts of products. For these big tech companies, common products include ads networks, chat, enterprise offerings, video watching, payments, hardware products, industry-leading AI tools, internal tools, etc. Microsoft, Amazon, Apple and ByteDance have products in some of these areas as well. For many big companies, they are large enough that they build their own infra and internal tools for most technologies they use because most existing technologies on the market can't meet their scale.
|
||||
|
||||
That said, each tech company is uniquely known for something and it's in their DNA. So if you are interested in specific areas and you are sure you can be able to work on them, the choice should be clearer:
|
||||
|
||||
- Meta/Facebook - Social networks (Facebook, Instagram), chat (WhatsApp, Messenger), Metaverse stuff (Oculus)
|
||||
- Google - Search, browsers (Google Chrome), Google Maps, cloud infrastructure (Google Cloud Platform), enterprise collaboration (Google Suite)
|
||||
- Amazon - Cloud infrastructure (Amazon Web Services), e-commerce
|
||||
- Microsoft - Operating systems, Microsoft Office Suite
|
||||
- Apple - Hardware, operating systems, services (iCloud, Apple Music)
|
||||
|
||||
Personally I feel more motivated and productive if I'm working on products which I use as an external user as well, as I have a better understanding of the product from a user perspective which can potentially lead to better engineering and product decisions.
|
||||
|
||||
### Prospective teams
|
||||
|
||||
While a company can be working on various products, some products are only worked on in certain offices. For example, Google Singapore primarily works on Payments and if you're only interested in working on search, Google Singapore wouldn't be that great of a fit, although it is definitely a possibility to relocate to another country in future while still remaining as a Google employee. More on that on the [Transfers and mobility](#transfers-and-mobility) section below.
|
||||
|
||||
Do find out what products and teams your intended location works on so that you have a better idea of how your potential working life looks like if you were to join that company.
|
||||
|
||||
## Company prospects
|
||||
|
||||
If you are awarded stocks, the company's prospects will affect your compensation! Is the company poised to be successful in the coming years or are there factors hindering the company's progress?
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Career growth
|
||||
|
||||
How fast does the company promote its employees and does the company provide opportunities for its employees to grow? In smaller companies, you will get to wear multiple hats and build many products from 0 to 1. It's great for people who like to grow their product building skills and launch products quickly. However, technical growth might be limited due to the company's focus on product work and less on building infrastructure, which is usually only needed at scale. There's little need for a Principal Engineer in a small startup of 10 people where everyone is scrambling to build products. Career growth might be limited by the size and scope of the company and its product offerings.
|
||||
|
||||
Some companies promote their employees faster than the others. There's a saying that go to Google to rest and vest, go to Meta if you want to accelerate your career. I've found this to be quite accurate from what I experienced and from looking at my peers at Google. At Meta, engineers are required to get from E3 to E4 within 2 years and E4 to E5 within 3 years. On the other hand, Google has a slower promotion cycle - the average engineer at Google takes more than 2 years to get from L3 to L4, more than 3 years to get from L4 to L5 and more than 4 years to get from L5 to L6. At Google, the terminal level is L4 so there's no pressure to promote. None of my peers are L6 at Google but a few are already E6 at Meta and it is quite achievable. In my opinion, Google is a great place to learn to be excellent engineers. They require everything to be well-engineered, with design docs and high test coverage. Meta is a great place for career-driven folks who don't mind working harder to accelerate their career path.
|
||||
|
||||
## Company culture
|
||||
|
||||
Company culture refers to the beliefs and behaviors of a company's leadership and its employees. The tech giants are famous for their unique cultures:
|
||||
|
||||
- Google - Candidates are evaluated for their "Googleyness" factor during interviews, which is a set of traits Google employees should embody - "Doing the right thing", "Striving for excellence", "Comfort with ambiguity". As mentioned above, Google is known for their high emphasis on engineering quality and data-driven decision making approach.
|
||||
- Meta/Facebook - In Facebook's early days, their internal motto was "Move fast and break things", indicating their focus on shipping products fast. In 2014, Mark Zuckerberg changed it to "Move fast with stable infrastructure" as the platform has matured and stability should a focus. I wrote more about [Meta/Facebook's culture in a blog post](https://www.techinterviewhandbook.org/blog/my-experience-working-as-a-meta-facebook-engineer/#culture).
|
||||
- Netflix - Netflix's culture deck is publicly available on [their website](https://jobs.netflix.com/culture) and their core philosophy is **people over process**. They like to think of themselves as professional sports teams - keeping the star players and letting adequate performers go instead of operating like a family - tolerating bad behavior and showing unconditional love
|
||||
|
||||
### Engineering culture
|
||||
|
||||
Since most readers are in tech roles, the tech culture of a company deserves special mention.
|
||||
|
||||
[Gergely Orosz](https://twitter.com/GergelyOrosz) came up with [12 points](https://blog.pragmaticengineer.com/pragmatic-engineer-test/) to evaluate whether a tech company has a healthy software engineering culture
|
||||
|
||||
1. **Equity or profit sharing** - Do employees receive equity?
|
||||
1. **Roadmap/backlog that engineers contribute to** - Do engineers contribute to the roadmap of their team?
|
||||
1. **Engineers directly working with other ICs** - Do engineers work directly with other roles (Designers, PMs, Data Scientists, etc)?
|
||||
1. **Code reviews and testing** - Do engineers peer code reviews and write tests often?
|
||||
1. **CI and engineers pushing to prod** - Is there continuous integration or a way for engineers to deploy to production?
|
||||
1. **Internal open source** - Can engineers access and contribute to code bases across the company?
|
||||
1. **Healthy oncall as a priority** - Is the oncall load manageable?
|
||||
1. **Technical managers** - Do the engineering managers possess technical background adn skills?
|
||||
1. **Career ladder (when above 10 engineers)** - Are career ladders and expectations for each level well-defined?
|
||||
1. **Parallel IC & manager tracks (when above 30 engineers)** - Can one rise up the career ladder as an IC?
|
||||
1. **Feedback culture** - Is it the practice to give feedback to each other/the company?
|
||||
1. **Investing in professional growth** - Stipend for professional growth, mentorship program
|
||||
|
||||
It's no surprise that the FAANG companies hit all 12 points. Read more about it on [his blog post](https://blog.pragmaticengineer.com/pragmatic-engineer-test/).
|
||||
|
||||
Which company's culture resonates with you the most?
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Work-life balance
|
||||
|
||||
While the common practice is for employees to work 40 hours a week and 8 hours a day, some places are infamous for being more stressful and asks more time from their employees. Some Chinese companies famously [require employees to work 6 days a week](https://www.reuters.com/world/china/chinese-tech-workers-disclose-working-hours-criticism-996-2021-10-14/). Most tech employees do not get paid when they work overtime, so sometimes a more accurate way of calculating your salary is dollars per hour instead of the raw annual total compensations
|
||||
|
||||
Google is famous for being a company for moving slower and a place where people go to rest and vest (their stocks) while [Amazon scored a C- for work-life balance](https://www.comparably.com/companies/amazon/work-life-balance) in an employee survey.
|
||||
|
||||
## Transfers and mobility
|
||||
|
||||
Does the company have offices around the globe where employees can possibly relocate to? This is obviously out of the question for smaller companies where there is only one headquarters, but some companies allow employees to be remote and some are even entirely remote! Meta, Google, Apple, and Stripe are examples of companies which have global presence and regional headquarters. At Meta and Google, mobility is extremely high given there are large engineering offices all across US, in London, Tel Aviv, and more recently, in Singapore. One of my managers at Meta has worked at **four** offices! Personally, I relocated from Meta/Facebook Menlo Park to Meta/Facebook Singapore right before COVID hit and a few of my Meta/Googler friends have done similar moves, some even moving from Singapore to the US.
|
||||
198
apps/website/contents/coding-interview-cheatsheet.md
Normal file
198
apps/website/contents/coding-interview-cheatsheet.md
Normal file
@@ -0,0 +1,198 @@
|
||||
---
|
||||
id: coding-interview-cheatsheet
|
||||
title: 'Coding interview cheatsheet: Best practices before, during and after'
|
||||
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 before, during, and after
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/coding-interview-cheatsheet.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
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.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## 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 hash table. For subsequent values, look up the hash table 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.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
### 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.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## 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.
|
||||
165
apps/website/contents/coding-interview-prep.md
Normal file
165
apps/website/contents/coding-interview-prep.md
Normal file
@@ -0,0 +1,165 @@
|
||||
---
|
||||
id: coding-interview-prep
|
||||
title: 'Coding interviews: Everything you need to prepare'
|
||||
description: What to expect, how to prepare and how to excel in software Engineer coding interviews
|
||||
keywords:
|
||||
[
|
||||
coding interview prep,
|
||||
coding interview,
|
||||
software engineer interview prep,
|
||||
software engineer coding interview,
|
||||
technical interview prep,
|
||||
technical interview,
|
||||
questions to practice,
|
||||
topics to study,
|
||||
how to prepare for coding interview,
|
||||
how to prepare for technical interview,
|
||||
]
|
||||
sidebar_label: Step-by-step how to prepare
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/coding-interview-prep.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
_The ultimate guide on how to efficiently prepare for your software engineering technical interview - coding test round._
|
||||
|
||||
If you have decided to embark on the arduous process of preparing for your coding interviews and you don't know how to maximize your time, this is the only guide you need to go from zero to hero on your coding test.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## What is a Software Engineering coding interview?
|
||||
|
||||
Coding interviews are a form of technical interviews used to access a potential software engineer candidate's competencies through presenting them with programming problems. Typically, coding interviews have a focus on data structures and algorithms, while other technical rounds may encompass [system design](./system-design.md) (especially for middle to senior level candidates).
|
||||
|
||||
A coding interview round is typically 30 - 45 minutes. You will be given a technical question (or questions) by the interviewer, and will be expected to write code in a real-time collaborative editor such as CodePen or CoderPad (phone screen / virtual onsite) or on a whiteboard (onsite) to solve the problem within 30–45 minutes.
|
||||
|
||||
## How will you be evaluated during a coding interview?
|
||||
|
||||
I have collated evaluation criteria across top tech companies and generalized them into a [coding interview evaluation rubric](./coding-interview-rubrics.md) you can use. Specific terminology or weightages may differ across companies, top tech companies always include the following criteria in their evaluation:
|
||||
|
||||
1. **Communication** - Asking clarifying questions, communication of approach and tradeoffs clearly such that the interviewer has no trouble following.
|
||||
1. **Problem solving** - Understanding the problem and approaching it systemically, logically and accurately, discussing multiple potential approaches and tradeoffs. Ability to accurately determine time and space complexity and optimize them.
|
||||
1. **Technical competency** - Translating discussed solutions to working code with no significant struggle. Clean, correct implementation with strong knowledge of language constructs.
|
||||
1. **Testing** - Ability to test code against normal and corner cases, self-correcting issues in code.
|
||||
|
||||
Read more about [how you should behave in a coding interview to display hire signals](./coding-interview-cheatsheet.md).
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## How to best prepare for a coding interview?
|
||||
|
||||
LeetCode by itself is actually not enough to prepare you well for your coding interviews. Diving straight into LeetCode and thinking you can complete all of the thousands of questions is a bad use of your time and will never prepare you as well as a structured approach.
|
||||
|
||||
Given 30 min per question and an average of 3 hours practice a day, the average person will only manage to complete 160 questions within 3-4 weeks, and may not internalize the right approach or remember the questions they have practiced before.
|
||||
|
||||
Instead, this is how to prepare for your Software Engineer coding interview:
|
||||
|
||||
1. [Pick a good programming language to use](#pick-programming-language)
|
||||
1. [Plan your time and tackle topics and questions in order of importance](#plan)
|
||||
1. [Combine studying and practicing for a single topic](#study-and-practice)
|
||||
1. [Accompany practice with coding interview cheat sheets to internalize the must-dos and must-remembers](#practice-with-cheatsheets)
|
||||
1. [Prepare a good self introduction and final questions](#prepare-self-introduction)
|
||||
1. [Try out mock coding interviews (with Google and Facebook engineers)](#mock-interviews)
|
||||
1. [(If you have extra time) Internalize key tech interview question patterns](#question-patterns)
|
||||
|
||||
### 1. Pick a good programming language to use {#pick-programming-language}
|
||||
|
||||
A good programming language to use for coding interviews is one you are familiar with and is suitable for interviews.
|
||||
|
||||
What determines if a programming language should be used for interviews? Generally, we want higher level languages that have many standard library functions and data structures and are therefore "easier" to code in.
|
||||
|
||||
Recommended programming languages to use for coding interviews: Python, C++, Java, JavaScript
|
||||
|
||||
Read more about [considerations for picking a programming language](./programming-languages-for-coding-interviews.md) here.
|
||||
|
||||
### 2. Plan your time and tackle topics and questions in order of importance {#plan}
|
||||
|
||||
How long does it take to prepare for a coding interview? It actually depends on how well prepared you want to be. On average, it takes about [30 hours to cover the bare minimum and ~100 hours to be well prepared](./coding-interview-study-plan.md).
|
||||
|
||||
To start preparing for your coding interviews, always begin with a plan. Calculate the amount of time you have left to realistically prepare for your interview from now till the day of the coding test, and carefully make a plan of the topics and questions you will cover per day, prioritizing the most important ones first.
|
||||
|
||||
But how do you know which are the most important topics and questions to practice based on the time you have left? You may use the free [Grind 75 tool](https://www.techinterviewhandbook.org/grind75) (built by me) which produces coding interview study plans for varying lengths of preparation time. The algorithm behind it includes a ranking of questions by priority and also a balance between breadth and depth of topics covered.
|
||||
|
||||
If you have the luxury of time to prepare, it is recommended to spend around 3 months (2-3 hours per day) to prepare more holistically. I came up with a [personal 3-month study plan](./coding-interview-study-plan.md), which takes you from start to finish on which topics and questions to complete.
|
||||
|
||||
### 3. Combine studying and practicing for a single topic {#study-and-practice}
|
||||
|
||||
For the sake of memory retention and efficiency, it is best to study for a single concept and then immediately do relevant practice questions for that topic.
|
||||
|
||||
Fortunately, there are already excellent coding interview preparation resources which enable you to do this very easily and systematically:
|
||||
|
||||
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://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
|
||||
#### [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://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
|
||||
This course by Design Gurus 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!** [**Get lifetime access today →**](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
|
||||
<InDocAd />
|
||||
|
||||
### 4. Accompany practice with coding interview cheatsheets to internalize the must-dos and must-remembers {#practice-with-cheatsheets}
|
||||
|
||||
To maximize what you get out of your practice, I recommend referring to the following coding interview cheatsheets _while_ you are studying and practicing:
|
||||
|
||||
- **Coding interview techniques**: how to find a solution and optimize your approach
|
||||
- **Coding interview best practices**: how to behave through the interview to exhibit hire signals
|
||||
- **Algorithms study cheatsheets**: covers the best learning resources, must remembers (tips, corner cases) and must do practice questions for every data structure and algorithm
|
||||
|
||||
#### Coding interview techniques
|
||||
|
||||
Here is [list of around 10 techniques](./coding-interview-techniques.md) to do the 2 most important things you need to do in a coding interview: finding approaches to solve the problem presented, and optimizing the time and space complexity of your approaches.
|
||||
|
||||
These techniques are useful to apply when you are given questions which you have never encountered before, and to get out of being stuck.
|
||||
|
||||
#### Coding interview best practices
|
||||
|
||||
Top tech companies evaluate candidates on 4 main criteria: communication, problem solving, technical competency and testing. To exhibit behaviors that fulfill these criteria, I have prepared a [coding interview best practices cheatsheet](./coding-interview-cheatsheet.md) which outlines what you should do before, during and after coding interviews. This is based on my personal experience as an interviewee as well as my observation of top candidates as an interviewer at Facebook.
|
||||
|
||||
Using this guide to accompany practice ensures that you cultivate good habits and muscle memory with regards to interviews right from the beginning.
|
||||
|
||||
#### Algorithms study cheatsheets for coding interviews
|
||||
|
||||
These are actually the notes I personally collated for my own coding interview preparation. I have organized them into 1-pagers of the best study resources, best LeetCode questions to practice, and must-remembers (tips, corner cases) for every data structure and algorithm. They ensure that you internalize the most important concepts and get the most out of your preparation. [Check them out](./algorithms/study-cheatsheet.md).
|
||||
|
||||
### 5. Prepare a good self introduction and final questions {#prepare-self-introduction}
|
||||
|
||||
Self introductions and final questions to ask are almost always required at the start and end of any software engineering interview. As such, you should always spend some time to craft an excellent self introduction and set of final questions to ask. When done well, these can leave a good impression with the interviewer that can turn things to your favor.
|
||||
|
||||
For the best software self introduction samples and tips, check out this [self introduction guide for software engineers](./self-introduction.md). Also check out samples of the best final questions to ask for software engineers in this [final questions guide](./final-questions.md).
|
||||
|
||||
### 6. Try out mock coding interviews {#mock-interviews}
|
||||
|
||||
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. 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 very 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.
|
||||
|
||||
Read more about [different mock coding interview platforms here](./mock-interviews.md).
|
||||
|
||||
### 7. (If you have extra time) Internalize key tech interview question patterns {#question-patterns}
|
||||
|
||||
Many coding interview solutions actually involve a similar set of key patterns - and learning them will help you solve any long tail problem that is outside the set of commonly asked coding interview questions.
|
||||
|
||||
#### AlgoMonster
|
||||
|
||||
Out of the resources on the internet - AlgoMonster is an excellent platform created by Google engineers. It uses a data-driven approach to condense software engineering coding interview questions into a set of key patterns, and summarized them into a structured, easy to digest course. Imagine LeetCode, but with only the key patterns you need to know.
|
||||
|
||||
Best of all, AlgoMonster is not subscription-based - pay a one-time fee and get lifetime access. [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
|
||||
|
||||
This course by Design Gurus 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.
|
||||
|
||||
Learn and understand patterns, not memorize answers! [Join today for a 10% discount →](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
|
||||
---
|
||||
|
||||
And that is all from me - for more detail on each step of the software engineer coding interview preparation process, do dive into each topic within my handbook through the sidebar or by navigating to the next page!
|
||||
155
apps/website/contents/coding-interview-rubrics.md
Normal file
155
apps/website/contents/coding-interview-rubrics.md
Normal file
@@ -0,0 +1,155 @@
|
||||
---
|
||||
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
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/coding-interview-rubrics.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
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-cheatsheet.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.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## 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 | No trouble achieving all basic problem solving signals and did so with enough time to achieve most advanced problem solving signals. |
|
||||
| Leaning hire | Managed to achieve all basic problem solving signals but did not have sufficient time to achieve advanced problem solving signals. |
|
||||
| Leaning no hire | Showed only some basic problem solving signals, failing to achieve the rest. |
|
||||
| Strong no hire | Unable to solve the problem or did it without much explanation of their thought process. Approach was disorganized and incorrect. |
|
||||
|
||||
<InDocAd />
|
||||
|
||||
### 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 basic and advanced competency signals effortlessly. |
|
||||
| Leaning hire | Demonstrated only basic technical competency signals, with some difficulty seen in translating approach to code. Suboptimal usage of language paradigms. |
|
||||
| Leaning no hire | Struggled to produce a working solution in code. Multiple syntax errors and bad use of language paradigms. |
|
||||
| Strong no hire | Could not produce a working solution in code. Major syntax errors and very bad use of language paradigms. |
|
||||
|
||||
### 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>
|
||||
127
apps/website/contents/coding-interview-study-plan.md
Normal file
127
apps/website/contents/coding-interview-study-plan.md
Normal file
@@ -0,0 +1,127 @@
|
||||
---
|
||||
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: Study and practice plan
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/coding-interview-study-plan.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd'; 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.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## 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 essential and recommended practice questions.
|
||||
|
||||
Don't forget to apply behaviors from [coding interview best practices](./coding-interview-cheatsheet.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 |
|
||||
|
||||
<InDocAd />
|
||||
|
||||
### 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.
|
||||
|
||||
- If you followed the Week 1 - 4 study plan, you would have done some of these questions here. Feel free to skip them or do them again.
|
||||
- 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-cheatsheet.md) and methods from [coding interview techniques](./coding-interview-techniques.md) early on while you practice!
|
||||
|
||||
We recommend using the [**Grind 75**](https://www.techinterviewhandbook.org/grind75/) tool which allows you to keep track of your practice progress.
|
||||
|
||||
<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).
|
||||
286
apps/website/contents/coding-interview-techniques.md
Normal file
286
apps/website/contents/coding-interview-techniques.md
Normal file
@@ -0,0 +1,286 @@
|
||||
---
|
||||
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 questions
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/coding-interview-techniques.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
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, and you can also use multiple techniques on one single 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 steps your iterator needs to take in each direction will help tremendously in 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, helps you to identify a pattern which can be generalized to any input, which is the solution! Lastly, the multiple examples can be used as test cases at the end when verifying your solution.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
### 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):
|
||||
# Fill in later
|
||||
pass
|
||||
|
||||
def group_strings(strings_hashes):
|
||||
# Fill in later
|
||||
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**: If you need to parse a string with nested properties (such as a mathematical equation), you will almost definitely need to use stacks.
|
||||
- **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.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## 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 hash table. If the lookup operation in your solution is the bottleneck to your solution's time complexity, more often than not, you can use a hash table 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.
|
||||
|
||||
##### Don't check conditions unnecessarily
|
||||
|
||||
These are Python examples where the second check is redundant.
|
||||
|
||||
- `if not arr and len(arr) == 0` - the first check already ensures that the array is empty so there is no need for the second check.
|
||||
- `x < 5 and x < 10` - the second check is a subcondition of the first check.
|
||||
|
||||
##### Mind the order of checks
|
||||
|
||||
- `if slow() or fast()` - There are two operations in this check, of varying durations. As long as one of the operations evaluates to `true`, the condition will evaluate to `true`. Most computers execute operations in order from left to right, hence it is more efficient to put the `fast()` on the left.
|
||||
- `if likely() and unlikely()` - This example uses a similar argument as above. If we execute `unlikely()` first and it is `false`, we don't have to execute `likely()`.
|
||||
|
||||
##### Don't invoke methods unnecessarily
|
||||
|
||||
If you have to refer to a property multiple times in your function and that property has to be derived from a function call, cache the result as a variable if the value doesn't change throughout the lifetime of the function. The length of the input array is the most common example. Most of the time, the length of the input array doesn't change, declare a variable at the start called `length = len(array)` and use `length` in your function instead of calling `len(array)` every time you need it.
|
||||
|
||||
##### Early termination
|
||||
|
||||
Early termination. Stop after you already have the answer, return the answer immediately. Here's an example of leveraging early termination. Consider this basic question "Determine if an array of strings contain a string regardless of case sensitivity". The code for it:
|
||||
|
||||
```py
|
||||
def contains_string(search_term, strings):
|
||||
result = False
|
||||
for string in strings:
|
||||
if string.lower() == search_term.lower():
|
||||
result = True
|
||||
return result
|
||||
```
|
||||
|
||||
Does this code work? Definitely. Is this code as efficient as it can be? Nope. We only need to know if the search term exists in the array of strings. We can stop iterating as soon as we know that there exists the value.
|
||||
|
||||
```py
|
||||
def contains_string(search_term, strings):
|
||||
for string in strings:
|
||||
if string.lower() == search_term.lower():
|
||||
return True # Stop comparing the rest of the array/list because the result won't change.
|
||||
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.
|
||||
|
||||
##### Minimize work inside loops
|
||||
|
||||
Let's further improve on the example above to solve the question "Determine if an array of strings contain a string regardless of case sensitivity".
|
||||
|
||||
```py
|
||||
def contains_string(search_term, strings):
|
||||
for string in strings:
|
||||
if string.lower() == search_term.lower():
|
||||
return True
|
||||
return False
|
||||
```
|
||||
|
||||
Note that you are calling `search_term.lower()` once per loop of the for loop! It's a waste because the `search_term` doesn't change throughout the lifecycle of the function.
|
||||
|
||||
```py
|
||||
def contains_string(search_term, strings):
|
||||
search_term_lowercase = search_term.lower()
|
||||
for string in strings:
|
||||
if string.lower() == search_term_lowercase:
|
||||
return True
|
||||
return False
|
||||
```
|
||||
|
||||
Minimize work inside loops and don't redo work you have already done if it doesn't change.
|
||||
|
||||
##### Be lazy
|
||||
|
||||
Lazy evaluation is an evaluation strategy which delays the evaluation of an expression until its value is needed. Let's use the same example as above. We could technically improve it a little bit:
|
||||
|
||||
```py
|
||||
def contains_string(search_term, strings):
|
||||
if len(strings) == 0:
|
||||
return False
|
||||
# Don't have to change the search term to lower case if there are no strings at all.
|
||||
search_term_lowercase = search_term.lower()
|
||||
for string in strings:
|
||||
if string.lower() == search_term_lowercase:
|
||||
return True
|
||||
return False
|
||||
```
|
||||
|
||||
This is considered a micro-optimization and most of the time, `strings` won't be empty, but I'm using it to illustrate the example where you don't have to do certain computations if they aren't needed. This also applies to initialization of objects that you will need in your code (usually hash tables). If the input is empty, there's no need to initialize any variables!
|
||||
|
||||
<InDocAd />
|
||||
|
||||
### 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 hash table 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-cheatsheet.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
|
||||
54
apps/website/contents/engineering-levels.md
Normal file
54
apps/website/contents/engineering-levels.md
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
id: engineering-levels
|
||||
title: Engineering levels
|
||||
---
|
||||
|
||||
:::caution
|
||||
|
||||
This section is still WIP. Feel free to contribute ideas at [our GitHub issue](https://github.com/yangshun/tech-interview-handbook/issues/222).
|
||||
|
||||
:::
|
||||
|
||||
Understanding the various career levels for engineers is crucial because it helps to determine the compensation you should be receiving and also helps you to understand what is expected of you at that level. In most companies where the career levels have been defined, it would resemble something along the lines of: Junior → Software Engineer → Senior → Staff → Senior Staff → Principal → Fellow
|
||||
|
||||
## Career levels
|
||||
|
||||
### Junior Software Engineer
|
||||
|
||||
_Work in progress_
|
||||
|
||||
### Software Engineer
|
||||
|
||||
_Work in progress_
|
||||
|
||||
### Senior Software Engineer
|
||||
|
||||
_Work in progress_
|
||||
|
||||
### Staff Software Engineer
|
||||
|
||||
_Work in progress_
|
||||
|
||||
### Senior Staff Software Engineer
|
||||
|
||||
_Work in progress_
|
||||
|
||||
### Principal Software Engineer
|
||||
|
||||
_Work in progress_
|
||||
|
||||
### Distinguished Engineer
|
||||
|
||||
_Work in progress_
|
||||
|
||||
### Fellow
|
||||
|
||||
_Work in progress_
|
||||
|
||||
#### References
|
||||
|
||||
- [Software Engineering Salaries at Google](https://careerkarma.com/blog/software-engineering-salary-google/)
|
||||
- [Dropbox Engineering Career Framework](https://dropbox.github.io/dbx-career-framework/overview.html)
|
||||
- [Engineering Levels at SoundCloud](https://developers.soundcloud.com/blog/engineering-levels)
|
||||
- [Every Public Engineering Career Ladder](https://www.swyx.io/career-ladders)
|
||||
- [progression.fyi](https://progression.fyi/)
|
||||
103
apps/website/contents/final-questions.md
Normal file
103
apps/website/contents/final-questions.md
Normal file
@@ -0,0 +1,103 @@
|
||||
---
|
||||
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,
|
||||
]
|
||||
sidebar_label: Preparing final questions to ask
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/final-questions.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
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. The ones in **bold** are the ones that tend to make the interviewer go "That's a good question" and pause and think for a bit.
|
||||
|
||||
## Best questions to ask for knowing more about technical work
|
||||
|
||||
- **What are the engineering challenges that the company/team is facing?**
|
||||
- **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 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?**
|
||||
- **I do/don't have experience in domain X. How important is this for me to be able to succeed?**
|
||||
- How do you evaluate new technologies? Who makes the final decisions?
|
||||
- How do you know what to work on each day?
|
||||
- How would you describe your engineering culture?
|
||||
- How has your role changed since joining the company?
|
||||
- What is your stack? What is the rationale for/story behind this specific stack?
|
||||
- Do you tend to roll your own solutions more often or rely on third party tools? What's the rationale in a specific case?
|
||||
- How does the engineering team balance resources between feature requests and engineering maintenance?
|
||||
- What do you measure? What are your most important product metrics?
|
||||
- How often have you moved teams? What made you join the team you're on right now? If you wanted to move teams, what would need to happen?
|
||||
- What resources does the company have for new hires to study its product and processes? Are there specifications, requirements, documentation?
|
||||
- How do you think my expertise would be relevant to this team? What unique value can I add?
|
||||
|
||||
## Best questions to ask for knowing more about the role
|
||||
|
||||
- **What qualities do you look out for when hiring for this role?**
|
||||
- **What would be the most important problem you would want me to solve if I joined your team?**
|
||||
- What does a typical day look like in this role?
|
||||
- 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?
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## Best questions to ask for knowing more culture and welfare
|
||||
|
||||
- **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 something you wish were different about your job?**
|
||||
- How is individual performance measured?
|
||||
- What do you like about working here?
|
||||
- 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
|
||||
|
||||
These questions are suitable for asking Engineering Managers or senior level management, such as CEO, CTO, VPs and are especially useful for the Team Matching phase of Google interviews or post-offer calls that your recruiters set up with the various team managers.
|
||||
|
||||
- **How do you train/ramp up engineers who are new to the team?**
|
||||
- **What does success look like for your team/project?**
|
||||
- **What are the strengths and weaknesses of the current team? What is being done to improve upon the weaknesses?**
|
||||
- **Can you tell me about a time you resolved an interpersonal conflict?**
|
||||
- How did you become a manager?
|
||||
- How do your engineers know what to work on each day?
|
||||
- What is your team's biggest challenge right now?
|
||||
- How do you measure individual performance?
|
||||
- How often are 1:1s conducted?
|
||||
- What is the current team composition like?
|
||||
- What opportunities are available to switch roles? How does this work?
|
||||
- Two senior team members disagree over a technical issue. How do you handle it?
|
||||
- Have you managed a poor performer at some point in your career before? What did you do and how did it work?
|
||||
- Where do you spend more of your time, high performers or low performers?
|
||||
- Sometimes there's a trade-off between what's best for one of your team members and what's best for the team. Give an example of how you handled this and why.
|
||||
- Give an example of a time you faced a difficult mentoring/coaching challenge. What did you do and why?
|
||||
- What is your management philosophy?
|
||||
- What is the role of data and metrics in managing a team like ours?
|
||||
- What role does the manager play in making technical decisions?
|
||||
- What is an example of a change you have made in the team that improved the team?
|
||||
- What would be the most important problem you would want me to solve if I joined your team?
|
||||
- What opportunities for growth will your team provide?
|
||||
- What would I work on if I joined this team and who would I work most closely with?
|
||||
|
||||
## Best questions to ask to know more about company direction
|
||||
|
||||
- **How does the company decide on what to work on next?**
|
||||
- What assurance do you have that this company will be successful?
|
||||
- Which companies are your main competitors and what differentiates your company?
|
||||
- What are your highest priorities right now? For example, new features, new products, solidifying existing code, reducing operations overhead?
|
||||
153
apps/website/contents/interview-formats-top-companies.md
Normal file
153
apps/website/contents/interview-formats-top-companies.md
Normal file
@@ -0,0 +1,153 @@
|
||||
---
|
||||
id: interview-formats-top-companies
|
||||
title: Interview format at top companies
|
||||
description: Interview formats of the top tech companies. Know what to expect and prepare well for them
|
||||
sidebar_label: Company interview formats
|
||||
---
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
:::info
|
||||
|
||||
Due to COVID travel restrictions, many companies hold interviews remotely even for the onsite rounds, so the instructions might differ.
|
||||
|
||||
:::
|
||||
|
||||
Are there companies you would like to know more about? Email us at [contact{at}techinterviewhandbook.org](mailto:contact@techinterviewhandbook.org).
|
||||
|
||||
## Airbnb
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interview:
|
||||
- 1 or 2 x Algorithm/front end on CoderPad/CodePen
|
||||
- Onsite (General):
|
||||
- 2 x Algorithm coding on CoderPad
|
||||
- 1 x System Design/architecture
|
||||
- 1 x Past experience/project
|
||||
- 2 x Cross functional
|
||||
- Onsite (Front End):
|
||||
- 2 x Front end coding on CodePen. Use any framework/library
|
||||
- 1 x General coding on your own laptop
|
||||
- 1 x Past experience/project
|
||||
- 2 x Cross functional
|
||||
- Tips:
|
||||
- All sessions involve coding on your own laptop. Prepare your development environment in advance
|
||||
- You are allowed to look up APIs if you need to
|
||||
- They seem to place high emphasis on compilable, runnable code in all their coding rounds
|
||||
- Cross functional interviews will involve getting Airbnb employees from any discipline to speak with you. These interviews are mostly non-technical but are extremely important to Airbnb because they place a high emphasis on cultural fit. Do look up the Airbnb section of the behavioral questions to know what sort of questions to expect
|
||||
|
||||
## Asana
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interview
|
||||
- Onsite (Product Engineer):
|
||||
- 3 x Algorithm and System Design on whiteboard within the same session
|
||||
- 1 x Algorithm on laptop and System Design. This session involves writing code on your own laptop to solve 3 well-defined algorithm problems in around 45 minutes after which an engineer will come in and review the code with you. You are not supposed to run the code while working on the problem
|
||||
- Tips:
|
||||
- No front end questions were asked
|
||||
- Asana places high emphasis on System Design and makes heavy use of the whiteboard. You do not necessarily have to write code for the algorithm question of the first three interviews
|
||||
- All 4 sessions involve algorithms and System Design. One of the sessions will be conducted by an Engineering Manager
|
||||
- The last session will involve coding on your own laptop. Prepare your development environment in advance
|
||||
- Regardless of Product Engineer or Engineering Generalist position, their interview format and questions are similar
|
||||
|
||||
## Dropbox
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interviews:
|
||||
- 2 x Algorithm/front end on CoderPad/CodePen
|
||||
- Onsite (Front End):
|
||||
- 2 x Front end on CodePen. Only Vanilla JS or jQuery allowed
|
||||
- 1 x General coding on CoderPad
|
||||
- 1 x All around. Meet with an Engineering Manager and discussing past experiences and working style
|
||||
- Tips:
|
||||
- You can code on your own laptop and look up APIs
|
||||
- Dropbox recruiters are very nice and will give you helpful information on what kind of questions to expect for the upcoming sessions
|
||||
- One of the front end sessions involve coding up a pixel-perfect version of a real page on the Dropbox website. You'll be given a spec of the desired page and you'll be asked to create a working version during the interview
|
||||
|
||||
## Google
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interview:
|
||||
- 1 or 2 x Algorithm on Google Doc
|
||||
- Onsite:
|
||||
- 1 or 2 x Front end on whiteboard. May be required to use Vanilla JS (or at the most, jQuery) depending on the question. (Front End only)
|
||||
- 2 to 4 x Algorithm on whiteboard
|
||||
- 1 x General Cognitive Ability, Leadership and "Googleyness".
|
||||
- Team matching
|
||||
- Speak with managers from different teams who are interested in your profile
|
||||
- Tips:
|
||||
- In rare cases, candidates may even be allowed to skip the phone interview round and advanced to onsite directly
|
||||
- For non-fresh grads, you only receive an offer if you are successfully matched with a team
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Indeed
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interview (optional)
|
||||
- Onsite:
|
||||
- 1 x Online Assessment on HackerRank (for L0 - L2)
|
||||
- 1 x Resume discussion
|
||||
- 1 or 2 x Algorithm on HackerRank
|
||||
- 1 x Code Review on GitHub
|
||||
- 1 or 2 x System Design (for L3+)
|
||||
- 1 x Technical Presentation (for L4+)
|
||||
- Tips:
|
||||
- If you are interviewing for a specific role, the bar varies
|
||||
- Hiring decision and leveling are separate discussions; leveling is determined by experience and leadership signals
|
||||
- If you do well in the interviews but the position is already filled, other hiring managers can pick up your packet
|
||||
|
||||
## Lyft
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interview:
|
||||
- 1 x Algorithm/Front end over JSFiddle
|
||||
- Onsite (Front End):
|
||||
- 4 x Front end on Coderpad/your own laptop. Use any language/framework
|
||||
- 1 x Behavioral. Meet with an Engineering Manager and go through candidate's resume
|
||||
- Tips:
|
||||
- Can use whiteboard and/or laptop
|
||||
- For front end coding, I opted to use React and had to set up the projects on the spot using `create-react-app`
|
||||
|
||||
## Meta (previously Facebook)
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interviews:
|
||||
- 1 or 2 x Algorithm/front end on Skype/CoderPad
|
||||
- Onsite:
|
||||
- 2 x Technical coding interview on whiteboard
|
||||
- 1 x Behavioral. Meet with an Engineering Manager and discussing past experiences and working style
|
||||
- 1 x Design/architecture on whiteboard
|
||||
- Onsite (University Grad):
|
||||
- 2 x Technical coding interview on whiteboard
|
||||
- 1 x Behavioral. Meet with an Engineering Manager and discussing past experiences and working style
|
||||
- Tips:
|
||||
- You are only allowed to use the whiteboard (or wall). No laptops involved
|
||||
- For the behavioral round, you may be asked a technical question at the end of it. Front end candidates will be given a small HTML/CSS problem nearing the end of the session
|
||||
- For the coding rounds, you may be asked one or more questions depending on how fast you progress through the question
|
||||
|
||||
## Palantir
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interview:
|
||||
- 1 x Algorithm over HackerRank CodePair and Skype
|
||||
- Onsite (General):
|
||||
- 2 x Algorithm on whiteboard
|
||||
- 1 x Decomposition (System Design) on whiteboard
|
||||
- Onsite (Front End):
|
||||
- 1 x Front end on your own laptop. This session lasts about 1.5 hours. Use any library/framework
|
||||
- 1 x Decomposition (System Design) on whiteboard
|
||||
- Tips:
|
||||
- I opted to use React and had to set up projects on the spot using `create-react-app`
|
||||
- You may be asked to meet with Engineering Managers after the technical sessions and it's not necessarily a good/bad thing
|
||||
|
||||
## WhatsApp
|
||||
|
||||
- Recruiter phone screen
|
||||
- Technical phone interview:
|
||||
- 2 x Algorithm over CoderPad
|
||||
- Onsite (Web Client Developer):
|
||||
- 4 x Algorithm on whiteboard
|
||||
- Tips:
|
||||
- No front end questions were asked
|
||||
- 1 of the interviewers is an Engineering Manager
|
||||
78
apps/website/contents/interviewer-cheatsheet.md
Normal file
78
apps/website/contents/interviewer-cheatsheet.md
Normal file
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: interviewer-cheatsheet
|
||||
title: Cheatsheet (Interviewer)
|
||||
---
|
||||
|
||||
This is a straight-to-the-point, distilled list of technical interview Do's and Don'ts **for interviewers**, mainly for algorithmic interviews. Some of these may apply to only phone screens or whiteboard interviews, but most will apply to both. I revise this list before each of my interviews as an interviewer to remind myself of them and eventually internalized all of them to the point I do not have to rely on it anymore.
|
||||
|
||||
**If you are a candidate you probably do not need to know this section well. You may read this to get a better sense of what an interviewer is supposed to do during an interview.**
|
||||
|
||||
#### Legend
|
||||
|
||||
- ✅ = Do
|
||||
- ❌ = Don't
|
||||
- ⚠️ = Situational
|
||||
|
||||
### Before interview
|
||||
|
||||
| | Things |
|
||||
| --- | --- |
|
||||
| ✅ | Make sure your surroundings are well-lit. |
|
||||
| ✅ | Find a quiet environment with good Internet connection. |
|
||||
| ✅ | Ensure webcam and audio are working. Test that your VC app is working well. |
|
||||
| ✅ | Prepare two to three questions and be familiar with the different approaches for solving the questions. Good questions have multiple solutions each with different tradeoffs. |
|
||||
| ✅ | Choose questions from different topics to identify possible knowledge gaps. |
|
||||
| ✅ | Familiarize yourself with the coding environment (CoderPad/CodePen). Set up the coding shortcuts, turn on autocompletion, tab spacing, etc. |
|
||||
|
||||
### Introduction
|
||||
|
||||
| | Things |
|
||||
| --- | --- |
|
||||
| ✅ | Check if candidate wants to use the restroom or take a break. |
|
||||
| ✅ | Give an overview of the interview format (introduction, duration, programming languages available, 5 min at the end for Q&A). |
|
||||
| ✅ | Do a self-introduction and get the candidate to introduce themselves. |
|
||||
| ✅ | Explain to candidate that there will be multiple questions (where relevant), they do not have to finish all questions and you might interrupt them abruptly. |
|
||||
| ❌ | Allow the candidate to spend too long introducing themselves. |
|
||||
|
||||
### Upon delivering the question
|
||||
|
||||
| | Things |
|
||||
| --- | --- |
|
||||
| ✅ | Ask if the candidate has seen the question before. |
|
||||
| ✅ | Give a small example for the question and the desired output. |
|
||||
| ✅ | Get the candidate to talk through the solution first before diving into coding. |
|
||||
| ✅ | Provide hints where appropriate. |
|
||||
| ✅ | If candidate is still stuck after providing hints, provide the solution and move to coding so that you can get coding signals. |
|
||||
|
||||
### During coding
|
||||
|
||||
| | Things |
|
||||
| --- | --- |
|
||||
| ✅ | If whiteboard interview, stand alongside candidate but also giving them space, instead of being distant, e.g. seated down. |
|
||||
| ✅ | Take note of all the [positive and negative signals](./coding-interview-rubrics.md). |
|
||||
| ✅ | If you have multiple questions, don't let the candidate spend too long on one question, especially if the first question is an Easy one. |
|
||||
| ❌ | Check the time in an overly-obvious manner. |
|
||||
|
||||
### After coding
|
||||
|
||||
| | Things |
|
||||
| --- | --- |
|
||||
| ✅ | Ask for candidate to provide test cases and run through the code with them. |
|
||||
| ✅ | Identify edge cases the candidate missed and ask the candidate to address them. Ask the candidate "What if X was the input? What would your code produce?" instead of pointing the issue out directly. |
|
||||
| ✅ | Take note of the duration the candidate spent on each question to include in the feedback. |
|
||||
| ✅ | Ask for time complexity and space analysis. |
|
||||
| ✅ | Preserve the code somewhere - take a picture or copy the code out. |
|
||||
| ✅ | Stop the candidate when there is 5 minutes left. e.g. ("I'll stop you here and let's go to the next section") |
|
||||
|
||||
### Wrap up
|
||||
|
||||
| | Things |
|
||||
| --- | --- |
|
||||
| ✅ | Allow candidate to ask questions and answer them to the best of your ability. |
|
||||
| ✅ | Thank the candidate and wish them all the best. |
|
||||
|
||||
### Post interview
|
||||
|
||||
| | Things |
|
||||
| --- | --------------------------------------------------------- |
|
||||
| ✅ | Write feedback as soon as possible to not forget details. |
|
||||
93
apps/website/contents/landscape.md
Normal file
93
apps/website/contents/landscape.md
Normal file
@@ -0,0 +1,93 @@
|
||||
---
|
||||
id: landscape
|
||||
title: Landscape
|
||||
---
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
import InternshipSalariesURL from '@site/static/img/internship-salaries.jpg';
|
||||
|
||||
Most of the content covered here will be specific to the Bay Area. Landscape differences due to geographical location are mentioned briefly [below](#geographical-location).
|
||||
|
||||
## Career prospects as a Software Engineer
|
||||
|
||||
### High demand
|
||||
|
||||
Almost every domain leverages on technology, hence Software Engineers are needed in almost every industry. Demand for engineers is higher than supply, leading to generally high-paying jobs. Moreover, the demand is continuously growing.
|
||||
|
||||
### Stable career
|
||||
|
||||
Computer Science is rapidly gaining popularity and engineering is a highly-regarded professional career. Unlike the creative industry, you do not have to be the top 1% of the industry to lead a comfortable life. An engineer fresh out of college working at a Silicon Valley company (both large companies and startups) can expect to receive a starting salary of more than USD 100,000 and it just gets better from there.
|
||||
|
||||
### Requires lifelong learning
|
||||
|
||||
Technology industry is an extremely fast-moving one. Many technologies used today didn't even exist/were popular a decade ago; in 2009, mobile app development and blockchain were pretty much unheard of. Engineers need to constantly upgrade their skills to stay relevant to the demands of the job market. Engineering is a great career for passionate individuals who like to learn.
|
||||
|
||||
### Flexible
|
||||
|
||||
A software engineering job is perhaps the most flexible job that exists in terms of hours, location and environment. Physical location is usually not an issue and there are many tech companies that are fully remote. There's no formal attire to be worn and working hours are generally flexible. Your co-workers would stare at you weirdly if you came to work wearing a shirt and tie.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## Internships vs full-time
|
||||
|
||||
If you dream of working at a top tech company one day, getting hired via an intern conversion is by far the easiest way to achieve that. Internship interviews are extremely short (usually just 2 rounds whereas interviews for full-time roles are usually 4-5 rounds). Internships allow you to work at a company over a short period of time (3 months or so) and helps in getting a first-hand understanding of the company and engineering culture. Companies also tend to give higher return job offers to high performing interns as they have proven to be effective at the job and can work with existing employees; hence hiring them is considered to be relatively low-risk.
|
||||
|
||||
Top tech companies pay a ridiculous amount even for junior candidates:
|
||||
|
||||
### United States
|
||||
|
||||
<div className="text--center">
|
||||
|
||||
<figure>
|
||||
<img alt="Salaries of top tech internships in 2016" src={InternshipSalariesURL} />
|
||||
|
||||
<figcaption>
|
||||
|
||||
Salaries of top US tech internships in 2016 ([source](https://twitter.com/rodneyfolz/status/724787290824798209))
|
||||
|
||||
</figcaption>
|
||||
</figure>
|
||||
|
||||
</div>
|
||||
|
||||
### Singapore
|
||||
|
||||
We ran a survey to find out what the famous tech companies in Singapore are paying new hires in 2022 and here's a sample of the results. View the [full dataset](https://docs.google.com/spreadsheets/d/1QtC8efWw0mVkGXW4QA9bX4f0nJhGbmFqCfVLSumMZ0I/) or [contribute your data](https://forms.gle/9oNNJJwespqWBZGw6)!
|
||||
|
||||
| Company | Internship (monthly in SGD) | Fresh Grad Annual Total (SGD) |
|
||||
| ------------- | --------------------------- | ----------------------------- |
|
||||
| Stripe | $6000 | $150,000 |
|
||||
| Meta/Facebook | $6000 | $140,000 |
|
||||
| Google | $5400 | $110,000 |
|
||||
| Shopee | $4200 | $100,000 - $140,000 |
|
||||
| ByteDance | $4000 | $85,000 |
|
||||
| Grab | $2500 | No data |
|
||||
| Visa | $2200 | $75,000 |
|
||||
|
||||
_Note: Fresh grad annual total numbers are approximate and include base salary, stock, and target bonuses._
|
||||
|
||||
## Company size
|
||||
|
||||
Companies have different focuses depending on the stage they are at and the types of work to be done can also be vastly different. In the earlier stages where product-market fit hasn't been found, companies would be rapidly iterating on products and features, whereas larger companies that have already found the right product will focus on scaling their infrastructure and growing their users. Liquid compensation is also lower at early-stage companies due to the equity not being worth any money, but there is the chance of earning a lot more if/when the company IPOs or gets acquired.
|
||||
|
||||
| Dimension | Early-stage startup | Late-stage startup | Large company |
|
||||
| --- | --- | --- | --- |
|
||||
| Company size | <100 | 100-1000 | >1000 |
|
||||
| Compensation | Base salary is a bit higher than big companies. Higher equity amount but its value is hard to judge as the company's valuation is unclear and stocks are not worth money yet. High risk, high return. | Base salary is a bit higher than big companies. Company valuation is clearer and stocks have higher chance of being worth money. | Depends on the prestige of the company. Compensation is usually market standard or better. Stocks are worth money if company has gone public. |
|
||||
| Types of work | Mainly product development. Engineers have to wear multiple hats - Front End, Back End, DevOps, Design, etc. | Product development and some infra. | Diverse roles and specialized work; dedicated people for each role. Infra and prod infra work is more common. More opportunities for internal transfers, sometimes even across the globe. |
|
||||
| Career ladder | Unstructured. No (or very vague) career levels. Not much formal mentorship nor training. | Somewhat structured. | Very structured. Well-defined career levels. |
|
||||
| Iteration speed | Extremely fast. Struggling to find product market fit. | Moderate. Has found product market fit, trying to grow user base. | Stable product with wide user base. Incrementally roll out changes and do lots of experimentation. |
|
||||
|
||||
_It's important to note that the above are just general trends and exceptions can apply._
|
||||
|
||||
## Geographical location
|
||||
|
||||
| | US (Silicon Valley/NY) | Singapore |
|
||||
| --- | --- | --- |
|
||||
| Starting Pay | USD 100,000 | Monthly $5243 (Median), $6316 (75th percentile) |
|
||||
| Talent Access | Global talent, diverse nationalities and backgrounds | Usually regional, mostly Asians |
|
||||
| Types of Companies | HQ of large companies (Facebook, Amazon, Apple, Google, Microsoft, etc), Startups | Branch offices of large companies, Startups |
|
||||
| Types of Engineering Work | Depends on size of office/company | Both product and infra (building new programming languages, frameworks, and tools) |
|
||||
|
||||
_Singapore salary data taken from [NUS GES 2020](https://www.moe.gov.sg/-/media/files/post-secondary/ges-2020/web-publication-nus-ges-2020.pdf)._
|
||||
35
apps/website/contents/mock-interviews.md
Normal file
35
apps/website/contents/mock-interviews.md
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
id: 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>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/mock-interviews.png" />
|
||||
</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](https://iio.sh/r/DMCa)
|
||||
|
||||
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](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](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.
|
||||
115
apps/website/contents/negotiation-rules.md
Normal file
115
apps/website/contents/negotiation-rules.md
Normal file
@@ -0,0 +1,115 @@
|
||||
---
|
||||
id: negotiation-rules
|
||||
title: Ten rules of negotiation
|
||||
description: Learn the basic rules of negotiation
|
||||
keywords:
|
||||
[
|
||||
FAANG,
|
||||
tech,
|
||||
jobs,
|
||||
negotiation,
|
||||
tips,
|
||||
software engineer,
|
||||
offer,
|
||||
total compensation,
|
||||
salary,
|
||||
]
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/negotiation.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
Key points extracted from "Ten Rules for Negotiating a Job Offer" [Part 1](http://haseebq.com/my-ten-rules-for-negotiating-a-job-offer/) and [Part 2](https://haseebq.com/how-not-to-bomb-your-offer-negotiation/) by Haseeb Qureshi.
|
||||
|
||||
## Get everything in writing
|
||||
|
||||
Note down EVERYTHING on your phone call with the recruiters as they may be helpful later on. Even if there are things that are not directly monetary, if they relate to the job, write them down. If they tell you "we're working on porting the front-end to Angular," write that down. If they say they have 20 employees, write that down. You want as much information as you can. You'll forget a lot of this stuff, and it's going to be important in informing your final decision.
|
||||
|
||||
## Always keep the door open
|
||||
|
||||
Never give up your negotiating power until you're absolutely ready to make an informed, deliberate final decision. This means your job is to traverse as many of these decision points as possible without giving up the power to continue negotiating. Very frequently, your interlocutor will try to trick you into making a decision, or tie you to a decision you didn't commit to. You must keep verbally jiu-jitsu-ing out of these antics until you're actually ready to make your final decision.
|
||||
|
||||
## Information is power
|
||||
|
||||
To protect your power in the negotiation, you must protect information as much as possible. A corollary of this rule is that you should not reveal to companies what you're currently making. So given this offer, don't ask for more money or equity or anything of the sort. Don't comment on any specific details of the offer except to clarify them. Companies will ask about your current compensation at different stages in the process—some before they ever interview you, some after they decide to make you an offer. But be mindful of this, and protect information.
|
||||
|
||||
> "Yeah, [COMPANY_NAME] sounds great! I really thought this was a good fit, and I'm glad that you guys agree. Right now I'm talking with a few other companies so I can't speak to the specific details of the offer until I'm done with the process and get closer to making a decision. But I'm sure we'll be able to find a package that we're both happy with, because I really would love to be a part of the team."
|
||||
|
||||
## Always be positive
|
||||
|
||||
Even if the offer is bad, it's extremely important to remain positive and excited about the company. This is because your excitement is one of your most valuable assets in a negotiation.
|
||||
|
||||
Despite whatever is happening in the negotiation, give the company the impression that 1) you still like the company, and that 2) you're still excited to work there, even if the numbers or the money or the timing is not working out. Generally the most convincing thing to signal this is to reiterate you love the mission, the team, or the problem they're working on, and really want to see things work out.
|
||||
|
||||
## Don't be the decision maker
|
||||
|
||||
Even if you don't particularly care what your friends/family/husband/mother thinks, by mentioning them, you're no longer the only person the recruiter needs to win over. There's no point in them trying to bully and intimidate you; the "true decision-maker" is beyond their reach. This is a classic technique in customer support and remediation. It's never the person on the phone's fault, they're just some poor schmuck doing their job. It's not their decision to make. This helps to defuse tension and give them more control of the situation.
|
||||
|
||||
> I'll look over some of these details and discuss it with my [FAMILY/CLOSE_FRIENDS/SIGNIFICANT_OTHER]. I'll reach out to you if I have any questions. Thanks so much for sharing the good news with me, and I'll be in touch!
|
||||
|
||||
It's much harder to pressure someone if they're not the final decision-maker. So take advantage of that.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## Have alternatives
|
||||
|
||||
If you're already in the pipeline with other companies (which you should be if you're doing it right), you should proactively reach out and let them know that you've just received an offer. Try to build a sense of urgency. Regardless of whether you know the expiration date, all offers expire at some point, so take advantage of that.
|
||||
|
||||
> Hello [PERSON],
|
||||
>
|
||||
> I just wanted to update you on my own process. I've just received an offer from [COMPANY] which is quite strong. That said, I'm really excited about [YOUR AMAZING COMPANY] and really want to see if we can make it work. Since my timeline is now compressed, is there anything you can do to expedite the process?
|
||||
|
||||
Should you specifically mention the company that gave you an offer? Depends. If it's a well-known company or a competitor, then definitely mention it. If it's a no-name or unsexy company, you should just say you received an offer. If it's expiring soon, you should mention that as well.
|
||||
|
||||
Either way, send out a letter like this to every single company you're talking to. No matter how hopeless or pointless you think your application is, you want to send this signal to everyone who is considering you in the market.
|
||||
|
||||
Companies care that you've received other offers. They care because each company knows that their own process is noisy, and the processes of most other companies are also noisy. But a candidate having multiple offers means that they have multiple weak signals in their favor. Combined, these converge into a much stronger signal than any single interview. It's like knowing that a student has a strong SAT score, and GPA, and won various scholarships. Sure, it's still possible that they're a dunce, but it's much harder for that to be true.
|
||||
|
||||
This is not to say that companies respond proportionally to these signals, or that they don't overvalue credentials and brands. They do. But caring about whether you have other offers and valuing you accordingly is completely rational.
|
||||
|
||||
Tell other companies that you've received offers. Give them more signals so that they know you're a valued and compelling candidate. And understand why this changes their mind about whether to interview you.
|
||||
|
||||
Your goal should be to have as many offers overlapping at the same time as possible. This will maximize your window for negotiating.
|
||||
|
||||
Have a strong BATNA (Best Alternative To a Negotiated Agreement) and communicate it.
|
||||
|
||||
> I 've received another offer from [OTHER CORP] that's very compelling on salary, but I really love the mission of [YOUR COMPANY] and think that it would overall be a better fit for me.
|
||||
|
||||
> I'm also considering going back to grad school and getting a Master's degree in Postmodern Haberdashery. I'm excited about [YOUR COMPANY] though and would love to join the team, but the package has to make sense if I'm going to forego a life of ironic hatmaking.
|
||||
|
||||
## Proclaim reasons for everything
|
||||
|
||||
It's kind of a brain-hack, both for yourself and for your negotiating partner. Just stating a reason (any reason) makes your request feel human and important. It's not you being greedy, it's you trying to fulfill your goals.
|
||||
|
||||
The more unobjectionable and sympathetic your reason, the better. If it's medical expenses, or paying off student loans, or taking care of family, you'll bring tears to their eyes.
|
||||
|
||||
Just go with it, state a reason for everything, and you'll find recruiters more willing to become your advocate.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## Be motivated by more than just money
|
||||
|
||||
You should be motivated by money too of course, but it should be one among many dimensions you're optimizing for. How much training you get, what your first project will be, which team you join, or even who your mentor will be—these are all things you can and should negotiate.
|
||||
|
||||
Of course, to negotiate well you need to understand the other side's preferences. You want to make the deal better for both of you.
|
||||
|
||||
## Understand what they value
|
||||
|
||||
Remember that you can always get salary raises as you continue to work at the company, but there's only one point at which you can get a signing bonus.
|
||||
|
||||
The easiest thing for a company to give though is stock (if the company offers stock). Companies like giving stock because it invests you in the company and aligns interests. It also shifts some of the risk from the company over to you and burns less cash.
|
||||
|
||||
## Be winnable
|
||||
|
||||
This is more than just giving the company the impression that you like them (which you continually should). But more so that you must give any company you're talking to a clear path on how to win you. Don't bullshit them or play stupid games. Be clear and unequivocal with your preferences and timeline.
|
||||
|
||||
Don't waste their time or play games for your own purposes. Even if the company isn't your dream company, you must be able to imagine at least some package they could offer you that would make you sign. If not, politely turn them down.
|
||||
|
||||
:::tip Expert tip
|
||||
|
||||
Get paid more. Receive salary negotiation help from [**Moonchaser**](https://www.moonchaser.io/?utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation) (risk-free) or [**Levels.fyi**](https://www.levels.fyi/services/?ref=TechInterviewHandbook&utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation) and their team of experienced recruiters. Don't leave money on the table 💰!
|
||||
|
||||
:::
|
||||
65
apps/website/contents/negotiation.md
Normal file
65
apps/website/contents/negotiation.md
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: negotiation
|
||||
title: Negotiation
|
||||
description: Learn the basics of negotiation and the services you can use to significantly increase your total compensation
|
||||
keywords:
|
||||
[
|
||||
FAANG,
|
||||
tech,
|
||||
jobs,
|
||||
negotiation,
|
||||
software engineer,
|
||||
offer,
|
||||
total compensation,
|
||||
salary,
|
||||
]
|
||||
sidebar_label: Complete salary negotiation guide
|
||||
---
|
||||
|
||||
<head>
|
||||
<title>What you need to know about negotiation | Tech Interview Handbook</title>
|
||||
<meta property="og:title" content="What you need to know about negotiation | Tech Interview Handbook"/>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/negotiation.png" />
|
||||
</head>
|
||||
|
||||
## Always negotiate
|
||||
|
||||
If you've received an offer (or even better, offers), congratulations! You may heave a huge sigh of relief and think that the toughest parts are over. Well yes, but not entirely! For most people, the reason they're finding a new job is to increase their salary, and salary negotiation is the last stretch in achieving that goal.
|
||||
|
||||
**Here's something that recruiters don't want you to know -** In most cases, there's room for negotiation on your offer and recruiters expect candidates to negotiate. **The initial offer that you are given is never the best package that the company can offer.** During my last job hunting experience, I received offers from numerous top tech companies like Facebook, Google, Airbnb, Lyft, Dropbox, and I have found this to be true. In most cases, you could always negotiate for more money, and some aspects of your salary is easier to negotiate than others. With multiple offers in hand, I was able to negotiate a better offer from every company.
|
||||
|
||||
## Negotiation services
|
||||
|
||||
If you haven't been negotiating your past offers, or are new to the negotiation game, worry not! There are multiple negotiation services that can help you out. Typically, they'd be well-worth the cost. Had I know about negotiation services in the past, I'd have leveraged them!
|
||||
|
||||
### Moonchaser
|
||||
|
||||
How Moonchaser works is that you will be guided by their experienced team of professionals throughout the entire salary negotiation process. It's also risk-free because you don't have to pay anything unless you have an increased offer. It's a **no-brainer decision** to get the help of Moonchaser during the offer process - some increase is better than no increase. Don't leave money on the table! Check out [Moonchaser](https://www.moonchaser.io/?utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation).
|
||||
|
||||
Things Moonchaser can do for you:
|
||||
|
||||
- Help you to negotiate increases even without competing offers
|
||||
- Provide tailored advice through their knowledge of compensation ranges at many companies
|
||||
- Provide you with customized scripts on what and how to talk to recruiters covering a range of scenarios
|
||||
- Mock negotiation services to help you practice
|
||||
- Provide you with live guidance during the recruiter call through chat
|
||||
- Introduce you to recruiters at other companies
|
||||
|
||||
<a className="button button--primary" href="https://www.moonchaser.io/?utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation">Book a free consultation with Moonchaser →</a>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
### Levels.fyi
|
||||
|
||||
[Levels.fyi](https://www.levels.fyi/services/?ref=TechInterviewHandbook&utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation) is most famously known for being a salary database but they also offer complementary services such as salary negotiation where you will be put in-touch with experienced recruiters to help you in the process. How Levels.fyi differs from Moonchaser is that Levels.fyi charges a flat fee whereas Moonchaser takes a percentage of the negotiated difference.
|
||||
|
||||
:::tip Expert tip
|
||||
|
||||
Get paid more. Receive salary negotiation advice from [**Moonchaser**](https://www.moonchaser.io/?utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation) (risk-free) or [**Levels.fyi**](https://www.levels.fyi/services/?ref=TechInterviewHandbook&utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation) and their team of experienced recruiters. Don't leave money on the table 💰!
|
||||
|
||||
:::
|
||||
|
||||
## Negotiation courses
|
||||
|
||||
If you are not keen on paying for negotiation services and are a fan of courses, here's something for you - the [Grokking Comp Negotiation in Tech](https://www.educative.io/courses/grokking-comp-negotiation?aff=x23W) course, a text-based course where you can get information on each aspect of negotiation. **Disclaimer: I haven't tried this course before.**
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
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
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/programming-languages-for-coding-interviews.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
Does the programming language you use for coding interviews matter? The answer is yes.
|
||||
|
||||
Most companies 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
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## 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.
|
||||
39
apps/website/contents/resume-old.md
Normal file
39
apps/website/contents/resume-old.md
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
id: resume-overview
|
||||
title: Resume overview
|
||||
sidebar_label: Overview
|
||||
---
|
||||
|
||||
Resume screening is the first stage in the interview process. It doesn't matter how strong you are in CS, algorithms or LeetCode, if you submit a poorly-written resume that doesn't pass the resume screening stage, your hopes are dashed. Hence it is important to nail this stage.
|
||||
|
||||
The following content is by Christina Ng and rephrased for the purpose of this handbook. You can follow her on [Medium](https://medium.com/@christinang89) or [Quora](https://www.quora.com/profile/Christina-Ng).
|
||||
|
||||
## How your resume is screened
|
||||
|
||||
While many engineers can be rather qualified for the role they are applying for, they miss out on getting a shot at the interview as they might never get past resume screening. The main issue was that they do not understand how recruiters worked.
|
||||
|
||||
Before writing your resume, it is important to understand the recruiting structure and how recruiting is done.
|
||||
|
||||
## The skill set checklist
|
||||
|
||||
Before opening up a position/starting the search for candidates, I usually consult very closely with the team manager/decision maker to find out the specific skill sets that are relevant for the position. These skill sets are typically grouped into "Must have", "Good to have", and "Special bonus".
|
||||
|
||||
- "Must have" — Typically, most of the must-haves include a degree (or not) in a relevant technical field, some years (or not) of experience in a particular programming language or technology
|
||||
- "Good to have" — Includes experience/familiarity with secondary languages/technologies which may not be directly relevant to what the candidate would be working on, but could be required due to some interfacing with other components of the project. It could also include softer skills such as being a good team player, clear communication, etc
|
||||
- "Special bonus" — Recognized skill sets/experiences which are difficult to come by. Probably not a requirement, but would definitely be useful for the position
|
||||
|
||||
Now that I am armed with this list, the search for candidates begin.
|
||||
|
||||
Typically, I do not seek that "one perfect candidate". What I seek for is the "best fit candidate". The search is essentially a numbers game. I know that for a specific job posting, there would perhaps be X applicants. At each stage of the interview process, some percentage of the candidates will be eliminated, leaving only a final Y% of the initial pool to choose from. Since Y tends to be a rather small number, recruiters will try to maximize X.
|
||||
|
||||
## The 10 seconds glance
|
||||
|
||||
When I am looking at your resume, I am doing a keyword match against the skill set checklist. If I see a good amount of the right keywords in your resume, it is a pass. If I need to spend more than 10 seconds trying to figure out what you are writing about, it is a fail. If I see an excessive amount of keywords (much looking like spam), it signals a red flag and goes into the "maybe". Depending on whether I think I have enough candidates for the day, you could eventually go into the pass or fail stack.
|
||||
|
||||
There are lots of articles writing about how recruiters only spend an average of about 10 seconds to screen each resume. The news is, this is true because resume screening is such a menial, robotic and repetitive task. In fact, many applicant tracking systems (ATS) now are so advanced that they can parse your resume automatically, search for specific keywords in your resume, and score your resume based on the weights pre-assigned to each keyword.
|
||||
|
||||
Finding a job is a two-way fit — the company wants someone with the relevant skills required, but it is also important for the applicant to fit in the company culture, and be able to gain something out of their stint. Hence, honesty is the single most important criteria in a resume.
|
||||
|
||||
There is a delicate balance between finding the right job vs. finding a job. Getting rejected does not always mean you are not good enough. Sometimes, it just means you are not a right fit for what the company is looking for.
|
||||
|
||||
When hiring fresh grads, I know that many of them will not have as much experience as someone who has years of industry experience. Hence, I would look out more for soft skills, such as attention to detail, initiative, passion, ability to get things done, etc. Note: this applies only if you have met the minimum threshold of proficiency/competency in the skill set checklist.
|
||||
366
apps/website/contents/resume.md
Normal file
366
apps/website/contents/resume.md
Normal file
@@ -0,0 +1,366 @@
|
||||
---
|
||||
id: resume
|
||||
title: Practical guide to writing FAANG-ready software engineer resumes
|
||||
description: How to write a top-tier, ATS-friendly resume good enough to pass resume screenings by Google, Amazon, Facebook and Microsoft
|
||||
keywords:
|
||||
[
|
||||
software engineer resume,
|
||||
FAANG software engineer resume,
|
||||
software engineer resume template,
|
||||
software engineer resume examples,
|
||||
software engineer resume sample,
|
||||
software engineer resume best practices,
|
||||
how to write software engineer resume,
|
||||
]
|
||||
sidebar_label: Writing your software engineer resume
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/resume.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
Not sure why you're still not getting shortlisted at some or all of the top tech companies? Your software engineer resume could be the issue.
|
||||
|
||||
Having read tons of software engineering resumes as a FAANG interviewer, even some of the most qualified candidates I know fail to get shortlisted due to bad resumes. The mistake most people make is to immediately assume that they weren't qualified enough - but that could be far from the truth.
|
||||
|
||||
Thankfully, there are specific steps and requirements you can fulfill to write a good software engineer resume. From your resume structure, content, to free tools you can use to test your resume, I have collated a very concise summary of the best practices to prepare your resume for a FAANG software engineering job application:
|
||||
|
||||
1. Set up an ATS-friendly resume template
|
||||
1. Fill up your template with well-framed content in a meaningful order
|
||||
1. Optimize your resume with prioritization and keywords
|
||||
1. Test out resume using free tools
|
||||
|
||||
## How to set up an ATS-friendly software engineer resume
|
||||
|
||||
Something most candidates may not realize is that most top tech companies are using some form of Applicant Tracking Systems (ATS) to parse and screen thousands of resumes even before they reach human eyes. In many companies, the ATS may even use certain rules to reject candidates automatically.
|
||||
|
||||
While different companies could be using different types of ATS, it is possible to ensure that your software engineer resume is read favorably by most ATS. This section ensures your resume is at least perfectly readable by the ATS, while the next few sections improve your chances of passing ATS screenings.
|
||||
|
||||
:::tip Expert tip
|
||||
|
||||
[FAANG Tech Leads](https://www.faangtechleads.com?utm_source=techinterviewhandbook&utm_medium=referral&utm_content=ats_template&aff=1e80c401fe7e2) is currently offering resume templates and examples at **70% off**.
|
||||
|
||||
Their templates:
|
||||
|
||||
- Are created by ex-FAANG hiring managers based on top resumes received from hundreds of candidate applications
|
||||
- Guarantee readability by FAANG ATS
|
||||
- Cater to various experience levels
|
||||
|
||||
They also offer resume examples/references from candidates who have received multiple offers from FAANG companies - which are helpful in helping you craft content that meets the same bar. [Check it out](https://www.faangtechleads.com?utm_source=techinterviewhandbook&utm_medium=referral&utm_content=ats_template&aff=1e80c401fe7e2)!
|
||||
|
||||
:::
|
||||
|
||||
### Only use Microsoft Word or Google Docs to create and edit your resume
|
||||
|
||||
**Do's**
|
||||
|
||||
- Submit your resume as a PDF file to preserve formatting, but always create it from Microsoft Word or Google Docs. It is important to ensure that the text in your resume is easily highlightable, which is a precondition for easy parsing.
|
||||
- ATS tools are always trying to improve their readability of standard resume formats - hence the more commonplace your resume format is, the better.
|
||||
- To maximize space on your resume, rather than using header or footers, reduce the margins of the page - narrow margins are 0.5 on each side.
|
||||
|
||||
**Don'ts**
|
||||
|
||||
- Do not use Photoshop, other graphic design tools or online resume builders to build your resume
|
||||
- Do not use the header or footer sections in a Word/Google Docs file - reduce margins instead and just write the information in the body.
|
||||
|
||||
### Only use standard fonts of readable sizes
|
||||
|
||||
New fonts may convert letters into special characters which are not readable by the ATS. Fonts you should use - **Arial, Calibri, Garamond**.
|
||||
|
||||
Ensure your font size remains readable for humans later on in the hiring process - use a minimum size of **10px** for readability.
|
||||
|
||||
### Add sections with standard headings and ordering
|
||||
|
||||
ATS readers need to identify and parse standard types of information from your resume. Using standard header titles and ordering can help them do that better.
|
||||
|
||||
This is the order which has worked well for me and recommended by recruiters:
|
||||
|
||||
| Section | Heading Name |
|
||||
| --- | --- |
|
||||
| Professional summary | (Use resume headline as section title, for e.g. "Senior Software Engineer at Google with over 5 years of experience leading teams") |
|
||||
| Contact information | "Contact Information" |
|
||||
| Skills - programming languages, frameworks, etc. | "Skills" |
|
||||
| Experience | "Work Experience" |
|
||||
| Education (Note: if you are still in school or have less than 3 years of experience, you may put Education first) | "Education" |
|
||||
| Projects | "Projects" |
|
||||
| Other optional sections - e.g. Certifications, Awards, etc | "Awards and Accolades" / "Certifications" / "Awards, Accolades and Certifications" |
|
||||
|
||||
:::caution
|
||||
|
||||
Never add symbols to your headers to avoid ATS readability issues.
|
||||
|
||||
:::
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## How to write good Software Engineer resume content
|
||||
|
||||
As software engineering is inherently different from other careers in terms of its required skills and experiences, the content expectations for a software engineer resume is also unique. Each of the following paragraphs will cover the content usually expected for software engineers within each resume section:
|
||||
|
||||
### How to write a professional summary for a software engineer
|
||||
|
||||
A good professional summary can be a game changer. Not only does it summarize your entire professional experience in a manner that individual sections cannot, it can also leave a pleasant impression on the hiring manager.
|
||||
|
||||
From my personal experience as a software engineering interviewer, I highly recommend professional summaries, as interviewers generally may not have the time to read into the detail - hence summaries which directly address why a candidate is a good fit for the job greatly improves their chances of capturing attention.
|
||||
|
||||
Here are my top tips for writing a great software engineering resume summary.
|
||||
|
||||
#### Before you start: List down your best selling points
|
||||
|
||||
From your entire professional experience, list down the most important points that fulfill the job descriptions that you are applying for. This can include job experiences or skills.
|
||||
|
||||
#### Summarize the selling points into your resume summary
|
||||
|
||||
Summarizing the selling points as much as possible, frame them into a short summary of less than 50 words:
|
||||
|
||||
Ensure you do these:
|
||||
|
||||
- ✅ Answer why you are a good fit for the job
|
||||
- ✅ Use an active voice
|
||||
- ✅ Use action words
|
||||
- ✅ Start with the noun describing your job role e.g. "Software Engineer", "Front End Engineer"
|
||||
|
||||
#### Write a headline for your resume summary
|
||||
|
||||
Instead of writing "Professional Summary" as the title of the section, further concise your experience into a headline with fewer than 10 words. Treat it like a slightly more elaborate version of your LinkedIn profile headline. Some examples"
|
||||
|
||||
##### Software Engineer (Full Stack)
|
||||
|
||||
Software Engineer with X years of full stack web development experience specializing in Ruby on Rails and PostgreSQL. Domain expert in e-commerce and payments field as a result of working at multiple e-commerce companies.
|
||||
|
||||
##### Senior Front End Engineer
|
||||
|
||||
Front End Engineer with X years of experience and strong fundamentals in Front End technologies. Likes building scalable web infrastructure and making websites fast. Passionate about programming languages, compilers, and developer tooling.
|
||||
|
||||
##### Software Engineering Lead
|
||||
|
||||
Software Engineer with X years of experience in back end, scaling complex distributed systems, and various cloud platforms. Led over 5 engineering teams with an average size of 6 members across two companies and mentored over 20 junior members.
|
||||
|
||||
##### Senior at University X
|
||||
|
||||
Senior Year student at University X with a focus on Artificial Intelligence and Machine Learning (ML). Interned at X companies and worked on full stack development and ML engineering roles.
|
||||
|
||||
:::info
|
||||
|
||||
Read more about how to make your Professional Summary stand out on [FAANG Tech Leads' Resume Handbook](https://www.faangtechleads.com/resume/professional-summary).
|
||||
|
||||
:::
|
||||
|
||||
### How to write contact information for a Software Engineer
|
||||
|
||||
#### Must-haves
|
||||
|
||||
- Name (Should be included at the very top of the resume)
|
||||
- Personal phone number
|
||||
- Never include your work phone number here
|
||||
- Location - City, State, Zip
|
||||
- Just enough for recruiters to determine if you are a local or international candidate
|
||||
- Email address
|
||||
- Never include your work email here
|
||||
- I recommend Gmail if you are using other email services
|
||||
- LinkedIn profile
|
||||
|
||||
#### Good-to-haves
|
||||
|
||||
- GitHub profile URL
|
||||
- Personal website URL
|
||||
- Stack Overflow profile URL
|
||||
- Medium profile URL
|
||||
- Competitive coding profile
|
||||
- CodeChef
|
||||
- HackerRank
|
||||
|
||||
If a divider is required between information, use "|" or tabs
|
||||
|
||||
Where relevant, indicate achievements in coding platforms, for example, max ratings, ranking, number of stars, badges.
|
||||
|
||||
:::info
|
||||
|
||||
Read more about getting your contact information section right with [FAANG Tech Leads' Resume Handbook](https://www.faangtechleads.com/resume/contact-information).
|
||||
|
||||
:::
|
||||
|
||||
### How to write skills for a Software Engineer
|
||||
|
||||
Include programming languages and tech stacks:
|
||||
|
||||
Structure in the following manner:
|
||||
|
||||
> [Skill summary] : [List skills separated by "|"]
|
||||
|
||||
- Programming languages - If impressive, include your familiarity by the number of lines you have written, for example "Over 10,000 lines"
|
||||
- Frameworks
|
||||
- Databases
|
||||
|
||||
:::info
|
||||
|
||||
Read more about listing your skills accurately right with [FAANG Tech Leads' Resume Handbook](https://www.faangtechleads.com/resume/skills).
|
||||
|
||||
:::
|
||||
|
||||
### How to write work experience for a Software Engineer
|
||||
|
||||
List your work experience in a familiar format and reverse chronological order. Every job listed should have:
|
||||
|
||||
The company, location, title, duration worked following this structure
|
||||
|
||||
> [Company or Organization], [Location] | [Job Title] | [Start and end dates formatted as MM/YYYY]
|
||||
|
||||
Example
|
||||
|
||||
> Facebook, Singapore | Front End Engineering Lead | 08/2018 - Present
|
||||
|
||||
List of top accomplishments, including:
|
||||
|
||||
- Scope of job and skills required
|
||||
- Accomplishments listed following this structure
|
||||
- > [Accomplishment summary] : [Action] that resulted in [quantifiable outcome]
|
||||
|
||||
:::info
|
||||
|
||||
Read more about presenting your conveying job experience well on [FAANG Tech Leads' Resume Handbook](https://www.faangtechleads.com/resume/work-experience).
|
||||
|
||||
:::
|
||||
|
||||
### How to write education for a Software Engineer
|
||||
|
||||
Most software engineering jobs will require at least an undergraduate degree. However, unless you are a recent graduate or do not have much work experience, it should not be prioritized above your work experience.
|
||||
|
||||
Use the following format, eliminating information where it is not relevant:
|
||||
|
||||
> [Degree Name], [Year of Graduation - write expected graduation date if not graduated]<br/>[University Name], [Location]<br/>GPA: X.XX / 4.0 (List GPA if more than 3.50/4.00, or more than 4.3 under a 5-point system)<br/>List key achievements, including leadership positions, skills, societies, projects, awards, etc.
|
||||
|
||||
Example:
|
||||
|
||||
> BSc in Computing, Computer Science, Graduation Year 2015<br/> National University of Singapore, Singapore <br/>GPA: 3.82 / 4.00 (Magna cum laude)<br/>Dean's List, Valedictorian<br/>President of hacker society
|
||||
|
||||
:::info
|
||||
|
||||
Read more about writing your education history on [FAANG Tech Leads' Resume Handbook](https://www.faangtechleads.com/resume/education).
|
||||
|
||||
:::
|
||||
|
||||
### How to write projects for a Software Engineer
|
||||
|
||||
Include at least 2 projects you have contributed to, outlining your key contributions. Always try to link your project name to GitHub or somewhere the hiring manager can view your project.
|
||||
|
||||
> [facebook/docusaurus](https://github.com/facebook/docusaurus) <br/>Maintainer and lead engineer for Docusaurus v2, a static site generator which powers the documentation of many of Meta's Open Source Projects - React Native, Jest, Relay, Reason, etc. Used by 7.6k > projects on GitHub.
|
||||
|
||||
### How to write awards, accolades and certifications for a Software Engineer
|
||||
|
||||
Only include achievements related to the job application and try to quantify your achievements. A good format to use would be
|
||||
|
||||
> [Year] [Quantification] [Competition]
|
||||
|
||||
Example
|
||||
|
||||
> 2016 | Best All-Round Product out of 50 teams | Facebook Hackathon
|
||||
|
||||
:::info
|
||||
|
||||
Read more about presenting your projects effectively on [FAANG Tech Leads' Resume Handbook](https://www.faangtechleads.com/resume/projects).
|
||||
|
||||
:::
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## Optimize your resume with keywords
|
||||
|
||||
must-haves to optimize your content:
|
||||
|
||||
### Less is more
|
||||
|
||||
**Do's**
|
||||
|
||||
- Highlighting a few of your best achievements is better than including many "average" achievements in your resume
|
||||
- Use only 1 page for your resume
|
||||
|
||||
**Don'ts**
|
||||
|
||||
- Do not list all your achievements just to showcase a greater quantity without filtering
|
||||
|
||||
### Keyword optimization
|
||||
|
||||
Imagine you are a hiring manager or recruiter screening a resume while juggling many other tasks in your job - you simply won't have much time on each resume! When a hiring manager looks at a resume, they are in fact quickly scanning for keywords of skills or experiences that they value, before paying any additional attention to your resume.
|
||||
|
||||
Recruiters and ATS do that as well, but based on the job description that the hiring manager helped to write. That is why optimizing your resume based on job descriptions is very important.
|
||||
|
||||
:::info
|
||||
|
||||
Some ATS will determine the strength of your skills based on the frequency of a keyword in your resume, and others assign an estimated amount of experience for a skill based on its placement in your resume.
|
||||
|
||||
For instance, if your previous job experience was 3 years long and you mentioned handling Search engine marketing (SEM), the ATS will assume 5 years of SEM experience.
|
||||
|
||||
:::
|
||||
|
||||
#### Include keywords from job descriptions into your resume
|
||||
|
||||
You should always analyze the job description for must-have and good-to-have skills or experiences and ensure the keywords are added to your resume.
|
||||
|
||||
Include them under the "Skills" section and pepper the same keywords into the "Work Experience" and "Education" sections. Be sure to closely imitate the language within the job description.
|
||||
|
||||
Remember to include the full version of common abbreviations as well. E.g. Amazon Web Services instead of AWS, Google Cloud Platform instead of GCP.
|
||||
|
||||
However, do not do keyword stuffing for the sake of it - always remember that the resume will be read by a recruiter or hiring manager eventually.
|
||||
|
||||
#### Optimize keyword frequency and placement
|
||||
|
||||
Analyze the job description and determine how important each skill and experience is, then optimize the frequency of the keyword according to its importance.
|
||||
|
||||
:::tip Expert tip
|
||||
|
||||
While optimizing for every application is ideal, you can generalize your resume to a type of position.
|
||||
|
||||
1. Collate 3 to 5 job descriptions for that position
|
||||
1. Copy and paste them into a `.txt` file and upload it into a free "word and phrase" frequency tool like [Online-Utility.org's Text Analyzer](https://www.online-utility.org/text/analyzer.jsp) to identify regularly used keywords
|
||||
1. Incorporate skills and experiences that you have into the resume
|
||||
|
||||
:::
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## Free tools to review your resume
|
||||
|
||||
I recommend using these free tools to optimize your resume:
|
||||
|
||||
### 1. Free resume review
|
||||
|
||||
[Resume Worded](https://a.paddle.com/v2/click/29828/144522?link=1861) uses AI to give instant expert feedback on your resume.
|
||||
|
||||
We previously recommended [TopResume's free all-in-one review](https://tidd.ly/3GxVIs9) of your resume, but received some feedback that that their reviewers are not technical and do not give feedback relevant to engineering roles. In that regard, we recommend [FAANG Tech Leads' Resume Review service (paid)](https://www.faangtechleads.com?utm_source=techinterviewhandbook&utm_medium=referral&utm_content=ats_template&aff=1e80c401fe7e2) where your resume will be reviewed by ex-FAANG hiring managers and engineers, not random writers who don't understand technology.
|
||||
|
||||
### 2. Test readability with industry-standard ATS
|
||||
|
||||
Test the readability and formatting of your resume using . Most big companies use such resume scanners.
|
||||
|
||||
### 3. The plain text file test
|
||||
|
||||
Simply copy the content from your resume and paste it into a plain text document! Make edits if:
|
||||
|
||||
- There are points missing from your original resume
|
||||
- Characters are displaying incorrectly in plain text
|
||||
- Sections are disorganized
|
||||
|
||||
## Final tips
|
||||
|
||||
### Do not take job application forms lightly
|
||||
|
||||
If the company you are applying for requires you to fill in the "Work Experience" and "Education" sections into their own form, do not take it lightly! Most of the time, these are internal HR applications which help parse job applications and filter out candidates from the information provided. In fact, it is possible that your resume is never seen by the recruiter or hiring manager - only the information that you fill up in their forms!
|
||||
|
||||
### Do not apply to many jobs at the same company
|
||||
|
||||
The ATS also allows recruiters to see all the roles you have applied to at their company. Try not to apply to too many jobs as a recruiter wouldn't be able to tell if you're actually interested in or if you're self-aware about your abilities. E.g. applying for a Software Engineer and a Data Scientist role at the same company is not a good idea.
|
||||
|
||||
---
|
||||
|
||||
And that is it from me in terms of resume preparation - hope this helps! If you have any other tips you would like to share with others on Tech Interview Handbook, do reach out to me at contact@techinterviewhandbook.org or create a new [GitHub discussion item](https://github.com/yangshun/tech-interview-handbook/discussions).
|
||||
|
||||
<div className="text--center margin-vert--lg">
|
||||
<figure>
|
||||
<img alt="Summary of the 4 steps to create a great software engineering resume, in checklist format"
|
||||
title="Summary checklist of the four key steps to create a great software engineering resume" className="shadow--md" src={require('@site/static/img/four-steps-to-create-a-software-engineer-resume.jpg').default} style={{maxWidth: 'min(100%, 420px)'}} />
|
||||
<figcaption>Summary checklist of the four key steps to create a great software engineering resume</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
112
apps/website/contents/self-introduction.md
Normal file
112
apps/website/contents/self-introduction.md
Normal file
@@ -0,0 +1,112 @@
|
||||
---
|
||||
id: self-introduction
|
||||
title: 'Software Engineer interviews: Crafting the perfect self introduction'
|
||||
description: How to answer "Tell me about yourself" for Software Engineer interviews
|
||||
keywords:
|
||||
[
|
||||
tell me about yourself software engineer,
|
||||
software engineer self introduction,
|
||||
software engineer self introduction sample,
|
||||
tell me about yourself software engineer example,
|
||||
self introduction software engineer sample,
|
||||
]
|
||||
sidebar_label: Preparing a self introduction
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/self-introduction.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
"Tell me about yourself" or "give me a quick introduction of your profile" is almost always the first question encountered in your software engineer interviews. This guide teaches you how to maximize this chance to impress the interviewer by crafting the perfect self introduction.
|
||||
|
||||
Interviewers want to work with candidates they like. Leave a good/deep impression and it will increase your chances of success. Most of us are not strangers to self introductions as we meet new people now and then and have to introduce ourselves every once in a while. However, self introductions in interviews are slightly different from real life - you need to tweak it to your advantage - tailor the self introduction to the role and company you are applying for! Your self introduction evolves as you grow and are at a different stage of your career.
|
||||
|
||||
When answering "tell me about yourself", you can rephrase the question into:
|
||||
|
||||
> "Tell me about your journey into tech. How did you get interested in coding, and why was web development (or replace with other job-specific skills) a good fit for you? How is that applicable to our role or company goals?" It is probably not a good idea to spend valuable time talking about things which aren't relevant to the job!
|
||||
|
||||
## Make an elevator pitch
|
||||
|
||||
An "elevator pitch" originates from a journalist trying to pitch an idea to an editor. The only time to catch the editor was in the elevator and she had only around 30 seconds to do so. The key elements of elevator pitches include:
|
||||
|
||||
- **Short** - You have limited time!
|
||||
- **Direct** - As you only have limited time, you should get to the point
|
||||
- **Attention-grabbing** - Present your most attractive ideas
|
||||
|
||||
Whether you're at a job fair with hundreds of other candidates and you have limited time or you are simply explaining who you are to a potential connection or client, it is important to be able to clearly and accurately describe your knowledge and skills quickly and succinctly. Your self introduction is an elevator pitch for yourself!
|
||||
|
||||
Here are some tips to develop a good elevator pitch for your software engineer self introduction:
|
||||
|
||||
### 1. Start with basic background information
|
||||
|
||||
Include who you are, who you work for (or school and major), and what you do.
|
||||
|
||||
- **Internships** - You should mention the following: name, school and major, focus areas, past internships and/or noteworthy projects
|
||||
- **Full-time** - You should mention the following: name, past companies, noteworthy projects (best if it's a public consumer product that they would have heard of)
|
||||
|
||||
Does this look familiar? It should be, because it is similar to your resume! Your resume is a condensed version of your knowledge and experiences and your self introduction is essentially a condensed version of your resume. As you grow older, professional experience becomes more important and school background becomes less important. Hence your self introduction changes as you become more senior.
|
||||
|
||||
### 2. KISS (Keep It Simple and Sweet)
|
||||
|
||||
Tell them some highlights from your favorite/most impressive projects and including some numbers if they're impressive or challenges that you've overcome. Do not delve into the depths of how you reverse engineered a game and decrypted a packet to predict when to use your DKP on a drop. Tell them the executive summary: "I reverse engineered X game by decrypting Y packet to predict Z." If this catches their interest, they might ask further questions on their own.
|
||||
|
||||
### 3. Why do they want you?
|
||||
|
||||
Tell the interviewer why you would make a good hire. Is your experience relevant to the company? Have you used a similar tech stack as the company or built relevant products? What unique talent(s) do you have that may give them confidence about your ability to contribute to the company?
|
||||
|
||||
### 4. Practice!
|
||||
|
||||
Lastly, you must practice your pitch! Having a great, succinct summary of your skills only helps if you can actually deliver it rapidly! You should practice keeping a quick but easy-to-follow pace that won't overwhelm them but won't bore them. It's a precarious balance, but can be ironed out with practice.
|
||||
|
||||
After coming up with your self introduction, keep it somewhere where you can refer/tweak in future. Memorize them and in future you can just use it when you need to but don't sound like you're recalling it from your memory when you're actually saying it out. Sound natural!
|
||||
|
||||
Having an elevator pitch on hand is a great way to create a network and chance upon new job opportunities. There will often be times when you can't prepare for an interview or meeting and it is incredibly handy to have a practiced pitch.
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## Good examples of software engineer self introductions
|
||||
|
||||
### Example 1: Front End Engineer at Meta
|
||||
|
||||
#### Self introduction
|
||||
|
||||
> "Hi I'm XXX and I graduated from National University of Singapore in 2015 with a degree in Computer Science. My interests are in Front End Engineering and I love to create beautiful and performant products with delightful user experiences.
|
||||
>
|
||||
> Back in school, I designed and built a web application, NUSMods which solves a huge problem of class and timetable planning every semester. It receives over a million pageviews a month and is used by over 40,000 NUS students and even some professors. It is built using a modern web technology stack - React, Redux, Jest, Babel, Flow, webpack and is mobile-responsive."
|
||||
>
|
||||
> I'm interested in the Front End Engineer role at Meta because I have been using Meta Open Source Front End technologies for a while now and am inspired by Meta's mission and Open Source culture.
|
||||
|
||||
#### Breakdown
|
||||
|
||||
- "I love to create beautiful and performant products with delightful user experiences."
|
||||
- Qualities that a Front End engineer should possess
|
||||
- "It receives over a million pageviews a month and is used by over 30,000 NUS undergraduates and even some professors."
|
||||
- Mention something about the project which stands out
|
||||
- "It is built using a modern web technology stack - React, Redux, Jest, Babel, Flow, webpack and is mobile-responsive."
|
||||
- Meta tech stack! Also hints that you keep yourself updated with modern web technologies
|
||||
|
||||
### Example 2: Front End Engineer at Lyft
|
||||
|
||||
#### Self introduction
|
||||
|
||||
> "Hi I'm XXX and I graduated from National University of Singapore in 2015 with a degree in Computer Science. My interests are in Front End Engineering and I love to create beautiful performant products with delightful user experiences.
|
||||
>
|
||||
> I previously worked at Grab where I led the Grab for Work project. Grab for Work was a service for companies to make corporate transportation expenses convenient. Companies can create employee groups, set ride policies and share corporate payment methods with their employees. I built the project with another engineer over the period of 3 months on a React/Redux and Golang stack."
|
||||
>
|
||||
> I'm interested in the Front End Engineer role at Lyft because I like working in this ridesharing space and creating products to improve the lives of users.
|
||||
|
||||
#### Breakdown
|
||||
|
||||
> "I love to create beautiful and performant products with delightful user experiences."
|
||||
|
||||
Same as above, qualities that a Front End engineer should possess.
|
||||
|
||||
> "I previously worked at Grab where I led the Grab for Work project."
|
||||
|
||||
Lyft was Grab's sister company! In fact they even had a partnership in the past. Most Lyft engineers would have heard of Grab before and mentioning this catches their attention.
|
||||
|
||||
> "I built the project with another engineer over the period of 4 months on a React/Redux and Golang stack."
|
||||
|
||||
Acknowledge that you work with others. Building a non-trivial system with just 2 people in 3 months is quite good for a non-trivial system. Lyft also uses Golang for their high performance systems.
|
||||
224
apps/website/contents/software-engineering-interview-guide.md
Normal file
224
apps/website/contents/software-engineering-interview-guide.md
Normal file
@@ -0,0 +1,224 @@
|
||||
---
|
||||
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'
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/software-engineering-interview-guide.png" />
|
||||
</head>
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
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 system design interview (for mid/senior levels)
|
||||
1. Prepare for the behavioral interview
|
||||
1. Negotiating the offer package
|
||||
|
||||
<InDocAd />
|
||||
|
||||
## 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-cheatsheet.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. [Grokking the Coding Interview: Patterns for Coding Questions](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
1. [AlgoMonster](https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=)
|
||||
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://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
|
||||
This course by Design Gurus 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!** [**Get lifetime access today →**](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-coding-interview)
|
||||
|
||||
#### 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-cheatsheet.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. [ByteByteGo](https://bytebytego.com?fpr=techinterviewhandbook) - This is a new System Design course by Alex Xu, author of the System Design Interview books, a bestseller on Amazon. The course covers system designs basics, then goes into deep dives of the design of over 10 famous common products (e.g. [Designing YouTube](https://bytebytego.com/courses/system-design-interview/design-youtube), Facebook Newsfeed, etc) and multiple big data and storage systems (e.g. [Designing a Chat System](https://bytebytego.com/courses/system-design-interview/design-a-chat-system)). For each deep dive, concepts are explained and comprehensive diagrams are used, making it very approachable for any seniority level.
|
||||
1. ["Grokking the System Design Interview" by Design Gurus](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-system-design-interview) - 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!
|
||||
1. ["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.
|
||||
1. ["Grokking the Advanced System Design Interview" by Design Gurus](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-advanced-system-design-interview) - 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!
|
||||
55
apps/website/contents/system-design.md
Normal file
55
apps/website/contents/system-design.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
id: system-design
|
||||
title: System design interview guide for Software Engineers
|
||||
description: How to prepare for system design interviews for Software Engineers
|
||||
keywords:
|
||||
[
|
||||
system design interview guide,
|
||||
how to prepare for system design interview,
|
||||
system design interview software engineer,
|
||||
]
|
||||
sidebar_label: System design preparation guide
|
||||
---
|
||||
|
||||
<head>
|
||||
<meta property="og:image" content="https://www.techinterviewhandbook.org/social/system-design.png" />
|
||||
</head>
|
||||
|
||||
The objective of system design interviews is to evaluate a candidate's skill at designing real-world software systems involving multiple components. System design questions are typically given to more senior candidates (with a few years of experience). Interns aren't typically given system design questions as it is hard to expect interns to have sufficient and relevant industry experience to answer this type of questions well.
|
||||
|
||||
Some common questions include:
|
||||
|
||||
- Design a URL shortener (e.g. Bitly)
|
||||
- Design a social media website (e.g. Twitter)
|
||||
- Design a video watching website (e.g. YouTube)
|
||||
- Design a chatting service (e.g. Telegram, Slack, Discord)
|
||||
- Design a file sharing service (e.g. Google Drive, Dropbox)
|
||||
- Design a ride sharing service (e.g. Uber, Lyft)
|
||||
- Design a photo sharing service (e.g. Flickr, Pinterest)
|
||||
- Design an e-commerce website (e.g. Amazon, eBay)
|
||||
- Design a jobs portal (e.g. LinkedIn, Indeed)
|
||||
- Design a web crawler (e.g. Google)
|
||||
|
||||
:::info
|
||||
|
||||
System design content is still work-in-progress, but the following are some resources to help you in the meanwhile.
|
||||
|
||||
:::
|
||||
|
||||
## Quality courses
|
||||
|
||||
- [ByteByteGo](https://bytebytego.com?fpr=techinterviewhandbook) - This is a new System Design course by Alex Xu, author of the System Design Interview books, a bestseller on Amazon. The course covers system designs basics, then goes into deep dives of the design of over 10 famous common products (e.g. [Designing YouTube](https://bytebytego.com/courses/system-design-interview/design-youtube?fpr=techinterviewhandbook), Facebook Newsfeed, etc) and multiple big data and storage systems (e.g. [Designing a Chat System](https://bytebytego.com/courses/system-design-interview/design-a-chat-system?fpr=techinterviewhandbook)). For each deep dive, concepts are explained and comprehensive diagrams are used, making it very approachable regardless of seniority level.
|
||||
- ["Grokking the System Design Interview" by Design Gurus](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-system-design-interview) - 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 refer 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 highly recommended many others to use this.
|
||||
- ["Grokking the Advanced System Design Interview" by Design Gurus](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-advanced-system-design-interview) - 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.
|
||||
- ["Best of System Design" package by Design Gurus](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fbundles%3Fbundle_id%3Dbuy-both-system-design-courses) - This bundle allows you to purchase both System Design interview courses by Design Gurus at a discount. Best of all, it's lifetime and not subscription-based.
|
||||
- ["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.
|
||||
|
||||
## Free resources
|
||||
|
||||
- [System Design Primer](https://github.com/donnemartin/system-design-primer) - Most comprehensive resource on system design out there. Recommended only if you have a ton of time to spare.
|
||||
- [System Design Interview](https://github.com/checkcheckzz/system-design-interview) - Contains many links to tips about system design, system design-related topics and engineering blogs of famous companies.
|
||||
- [System Design Cheatsheet](https://gist.github.com/vasanthk/485d1c25737e8e72759f) - Brief and concise content. Serves as a good revision right before your system design interview.
|
||||
|
||||
## Books
|
||||
|
||||
- [System Design Interview – An insider's guide, Second Edition](https://www.amazon.com/System-Design-Interview-insiders-Second/dp/B08CMF2CQF) - Beginner friendly resource to learn about system design, the content is easy to read and understand.
|
||||
112
apps/website/contents/understanding-compensation.md
Normal file
112
apps/website/contents/understanding-compensation.md
Normal file
@@ -0,0 +1,112 @@
|
||||
---
|
||||
id: understanding-compensation
|
||||
title: Understanding compensation
|
||||
---
|
||||
|
||||
import InDocAd from './\_components/InDocAd';
|
||||
|
||||
Compensation is one of the largest factors when it comes to deciding between job offers. This section gives you a breakdown of the common components of compensation in the tech industry.
|
||||
|
||||
In most companies, your compensation will consist of base salary, a performance bonus and equity/stocks. For compensation data, check out [Levels.fyi](https://www.levels.fyi?ref=TechInterviewHandbook&utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation).
|
||||
|
||||
## Base salary
|
||||
|
||||
Base salary is a fixed amount of salary you get for showing up at work and is unaffected by how well the company is performing or the industry is doing. It is the only non-variable component of your compensation.
|
||||
|
||||
Fresh graduates in the Bay Area can usually expect to get a base salary of above USD 100,000 (before taxes). The salary for fresh graduates at Facebook/Google is known to be in the USD 100,000 - 150,000 range.
|
||||
|
||||
Startups usually offer a bit higher for fresh graduate (USD 120,000 - 130,000) to make up for the lack of liquidity of the equity grant (not yet real cash).
|
||||
|
||||
Base salary doesn't increase linearly as you become more senior; it will taper off eventually. As employees become increasingly senior within the company, the higher the proportion of their compensation comes from company-dependent factors such as bonus and equity. This is because senior employees are expected to influence the people around them and drive the company forward. A senior employee's performance will be based on how well the company does as a whole; the individual factor will not be as much.
|
||||
|
||||
There are some exceptions to the system. Companies like Netflix pay top of the industry (sometimes even more than Facebook/Google) and give employees the option to receive their entire compensation as base salary, that is, to convert the equity component into their base. For the risk-adverse, this is a great choice.
|
||||
|
||||
## Bonus
|
||||
|
||||
Bonuses are usually paid on a semi-annual basis and are typically dependent on a few factors - level of seniority, individual performance in that time period, company performance in that time period.
|
||||
|
||||
- **Level of seniority** - This is usually a multiplier of the base salary and the multiplier increases as the employee moves up the ranks
|
||||
- **Individual performance** - This is a multiplier of how well an employee performed in that time period. E.g. meeting expectations results in a 100% multiplier and exceeding expectations results in a >100% multiplier. Companies like Facebook and Apple reward their top performers handsomely, and the multiplier can go up to 300% for the extremely high-performing employees
|
||||
- **Company performance** - How well the company is doing. This multiplier will be the same for all employees
|
||||
|
||||
### Examples
|
||||
|
||||
Bob is a Software Engineer fresh out of college. His base salary is $100,000, is a fresh grad (seniority multiplier: 10%), crushed expectations for the half (individual performance multiplier: 200%) and his company did pretty well (company performance multiplier: 120%). For that half, his bonus will be as follows:
|
||||
|
||||
**Bonus:** 100,000 x 50% (half a year) x 10% (seniority) x 200% (individual performance) x 120% (company performance) = 12000
|
||||
|
||||
Alice is an Engineering Manager with 10 years of professional experience. Her base salary is $220,000, is an experienced engineering manager (seniority multiplier: 20%), exceeded expectations for the half (individual performance multiplier: 150%) and her company did pretty awesome (company performance multiplier: 130%). For that half, her bonus will be as follows:
|
||||
|
||||
**Bonus:** 220,000 x 50% (half a year) x 20% (seniority) x 150% (individual performance) x 130% (company performance) = 42900
|
||||
|
||||
Hence the amount of bonus you receive can be highly variable and senior employees get a higher proportion of their total compensation from bonuses.
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Equity/stocks
|
||||
|
||||
Equity is what differentiates a tech job from a non-tech one. Equity means a share of the company; this signifies ownership and motivates employees to work in the best interests of the company. They can be a significant portion of one's compensation, sometimes even more than the base salary, especially for senior employees.
|
||||
|
||||
Equity usually vests (becomes available to you) over a period of time (typically 4 years) and can vest equally every month/quarter/year. A vesting cliff means the minimum period of time before your vesting begins. For example, if you are granted 4,800 shares over a 4 year schedule with a 1 year cliff, and monthly vesting, you will get 1,200 shares at the end of your first year and 100 shares every month thereafter for the subsequent 3 years.
|
||||
|
||||
Until the company goes public (IPO) or gets acquired, the equity is usually not worth anything. However, there are instances where you can sell your stocks internally even though the company hasn't gone public. Be mindful of what you are getting yourself into!
|
||||
|
||||
Not all equity is treated equally. Depending on the company you join and which stage that company is at, you may receive one of the following types: stock options or stock grants.
|
||||
|
||||
### Stock options
|
||||
|
||||
Stock options are typically given by mid-stage companies. Stock options are different from stocks, which represents the immediate ownership of a company! Stock options are the **option/right** to purchase stocks at a given strike price, hence it's not free. However, the cost of each stock is usually quite low and fixed at a strike price, which is equal to the fair market value of the stock when it was granted to you. You are guaranteed to be able to purchase the stock at that price regardless of future increases.
|
||||
|
||||
When you leave a company, there is an exercise window (deadline given for you to exercise your options before they are gone), so it is important to have enough liquid cash to purchase them when planning a departure.
|
||||
|
||||
### Stock grants
|
||||
|
||||
A stock grant is commonly referred to as a Restricted Stock Unit (RSU) and it means you possess the stock immediately. If the company is public, you can sell them during defined trading windows.
|
||||
|
||||
More reading on the topic can be done on the [equity compensation guide](https://github.com/jlevy/og-equity-compensation) and the article ["What I Wish I'd Known About Equity Before Joining A Unicorn"](https://gist.github.com/yossorion/4965df74fd6da6cdc280ec57e83a202d).
|
||||
|
||||
## Signing bonus
|
||||
|
||||
This is a one-time lump sum that is paid to you when you join a company. This amount is typically in the range of USD 10,000 to USD 20,000 but can even go up to USD 50,000 (Google) and USD 100,000 (Facebook).
|
||||
|
||||
There can be conditions attached to signing bonuses, such as having to return a pro-rated amount if an employee leaves before the one-year mark. Make sure you are aware of them before you sign the offer.
|
||||
|
||||
<InDocAd/>
|
||||
|
||||
## Misc bonuses/perks
|
||||
|
||||
While these perks are not exactly cash, they can help you save money which is almost equivalent to getting compensated more. Do find out more about these from your recruiters if you get the chance.
|
||||
|
||||
- **Free meals** - Food is not exactly cheap in the Bay Area and having some meals provided on weekdays can result in saving few thousand dollars a year and hours spent on travelling out to get food
|
||||
- **Relocation bonus** - Helpful if you are moving from abroad. This can partially offset costs incurred during relocation
|
||||
- **Health and dental insurance/plans** - Companies often partner with insurance companies to provide employees with health and dental plans. These can amount to a few thousand dollars worth annually and is especially useful in locations where healthcare is expensive
|
||||
- **Shuttle service** - Public transportation in the Bay Area is not that great and the most common form of commute is driving. Being able to take a shuttle service helps in saving money on gas, transport, and freeing up your mind to do other things during the commute
|
||||
|
||||
## Examples
|
||||
|
||||
Here's crowdsourced data from Google and Facebook regarding the salaries for the various levels:
|
||||
|
||||
### Google
|
||||
|
||||
| Level | Total (USD) | Base | Bonus | Stock (/yr) |
|
||||
| ----------------------- | ----------- | -------- | -------- | ----------- |
|
||||
| L3 (Entry Level) | $191,000 | $131,000 | $21,000 | $39,000 |
|
||||
| L4 (SWE) | $267,000 | $158,000 | $28,000 | $81,000 |
|
||||
| L5 (Senior SWE) | $355,000 | $188,000 | $37,000 | $130,000 |
|
||||
| L6 (Staff SWE) | $489,000 | $223,000 | $50,000 | $214,000 |
|
||||
| L7 (Senior Staff SWE) | $672,000 | $263,000 | $79,000 | $330,000 |
|
||||
| L8 (Principal Engineer) | $1,020,000 | $331,000 | $119,000 | $572,000 |
|
||||
|
||||
_Data as of Aug 2021. Source: [Levels.fyi](https://www.levels.fyi/company/Google/salaries/Software-Engineer/?ref=TechInterviewHandbook&utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation)_
|
||||
|
||||
### Facebook
|
||||
|
||||
| Level | Total (USD) | Base | Bonus | Stock (/yr) |
|
||||
| --------------------- | ----------- | -------- | ------- | ----------- |
|
||||
| E3 (Entry Level) | $180,000 | $122,000 | $14,000 | $43,000 |
|
||||
| E4 (SWE) | $267,000 | $162,000 | $18,000 | $85,000 |
|
||||
| E5 (Senior SWE) | $390,000 | $197,000 | $35,000 | $157,000 |
|
||||
| E6 (Staff SWE) | $598,000 | $234,000 | $54,000 | $309,000 |
|
||||
| E7 (Senior Staff SWE) | $921,000 | $272,000 | $81,000 | $567,000 |
|
||||
|
||||
_Data as of Aug 2021. Source: [Levels.fyi](https://www.levels.fyi/company/Facebook/salaries/Software-Engineer/?ref=TechInterviewHandbook&utm_source=techinterviewhandbook&utm_medium=referral&utm_content=website_negotiation)_
|
||||
227
apps/website/docusaurus.config.js
Executable file
227
apps/website/docusaurus.config.js
Executable file
@@ -0,0 +1,227 @@
|
||||
module.exports = {
|
||||
title: 'Tech Interview Handbook',
|
||||
tagline: 'Free curated interview preparation materials for busy people',
|
||||
url: 'https://www.techinterviewhandbook.org',
|
||||
baseUrl: '/',
|
||||
trailingSlash: true,
|
||||
favicon: 'img/favicon.png',
|
||||
organizationName: 'yangshun',
|
||||
projectName: 'tech-interview-handbook',
|
||||
themeConfig: {
|
||||
announcementBar: {
|
||||
id: 'algomonster-1', // Increment on change
|
||||
content: `Stop grinding mindlessly, study with a plan! Developed by Google engineers,
|
||||
<a href="https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=" target="_blank" rel="noopener">AlgoMonster</a> is the fastest way to get a software engineering job.
|
||||
<a href="https://shareasale.com/r.cfm?b=1873647&u=3114753&m=114505&urllink=&afftrack=" target="_blank" rel="noopener">Check it out now!</a>`,
|
||||
isCloseable: false,
|
||||
},
|
||||
prism: {
|
||||
theme: require('prism-react-renderer/themes/github'),
|
||||
darkTheme: require('prism-react-renderer/themes/dracula'),
|
||||
},
|
||||
navbar: {
|
||||
title: 'Tech Interview Handbook',
|
||||
logo: {
|
||||
alt: 'Tech Interview Handbook Logo',
|
||||
src: 'img/logo.svg',
|
||||
},
|
||||
hideOnScroll: true,
|
||||
items: [
|
||||
{
|
||||
label: 'Start reading',
|
||||
href: '/software-engineering-interview-guide/',
|
||||
position: 'left',
|
||||
},
|
||||
{
|
||||
label: 'Coding',
|
||||
href: '/coding-interview-prep/',
|
||||
},
|
||||
{
|
||||
label: 'Algorithms',
|
||||
href: '/algorithms/study-cheatsheet',
|
||||
},
|
||||
{ label: 'Blog', to: 'blog', position: 'left' },
|
||||
{
|
||||
label: 'Grind 75',
|
||||
href: 'https://www.techinterviewhandbook.org/grind75',
|
||||
position: 'left',
|
||||
},
|
||||
{
|
||||
label: 'Front End',
|
||||
href: 'https://www.frontendinterviewhandbook.com',
|
||||
position: 'left',
|
||||
},
|
||||
{
|
||||
href: 'https://github.com/yangshun/tech-interview-handbook',
|
||||
position: 'right',
|
||||
className: 'navbar-icon',
|
||||
'aria-label': 'GitHub repository',
|
||||
html: `<svg
|
||||
stroke="currentColor"
|
||||
fill="currentColor"
|
||||
stroke-width="0"
|
||||
viewBox="0 0 496 512"
|
||||
height="24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path>
|
||||
</svg>`,
|
||||
},
|
||||
{
|
||||
href: 'https://discord.gg/usMqNaPczq',
|
||||
position: 'right',
|
||||
className: 'navbar-icon',
|
||||
'aria-label': 'Discord channel',
|
||||
html: `<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 640 512" height="24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"></path></svg>`,
|
||||
},
|
||||
{
|
||||
href: 'https://t.me/techinterviewhandbook',
|
||||
position: 'right',
|
||||
className: 'navbar-icon navbar-icon-telegram',
|
||||
'aria-label': 'Telegram channel',
|
||||
html: `<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 448 512" height="24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M446.7 98.6l-67.6 318.8c-5.1 22.5-18.4 28.1-37.3 17.5l-103-75.9-49.7 47.8c-5.5 5.5-10.1 10.1-20.7 10.1l7.4-104.9 190.9-172.5c8.3-7.4-1.8-11.5-12.9-4.1L117.8 284 16.2 252.2c-22.1-6.9-22.5-22.1 4.6-32.7L418.2 66.4c18.4-6.9 34.5 4.1 28.5 32.2z"></path></svg>`,
|
||||
},
|
||||
{
|
||||
href: 'https://twitter.com/techinterviewhb',
|
||||
position: 'right',
|
||||
className: 'navbar-icon navbar-icon-twitter',
|
||||
'aria-label': 'Twitter page',
|
||||
html: `<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"></path></svg>`,
|
||||
},
|
||||
],
|
||||
},
|
||||
footer: {
|
||||
style: 'dark',
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Tech Interview Handbook. Built with Docusaurus.`,
|
||||
links: [
|
||||
{
|
||||
title: 'General',
|
||||
items: [
|
||||
{
|
||||
label: 'Start reading',
|
||||
href: '/software-engineering-interview-guide/',
|
||||
},
|
||||
{
|
||||
label: 'Prepare a FAANG-ready resume',
|
||||
href: '/resume/',
|
||||
},
|
||||
{
|
||||
label: 'Algorithms cheatsheets',
|
||||
href: '/algorithms/study-cheatsheet',
|
||||
},
|
||||
{
|
||||
label: 'Blog',
|
||||
href: '/blog',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Interviews',
|
||||
items: [
|
||||
{
|
||||
label: 'Coding interviews',
|
||||
href: '/coding-interview-prep/',
|
||||
},
|
||||
{
|
||||
label: 'Coding interview study plan',
|
||||
href: '/coding-interview-study-plan/',
|
||||
},
|
||||
{
|
||||
label: 'System design interviews',
|
||||
href: '/system-design/',
|
||||
},
|
||||
{
|
||||
label: 'Behavioral interviews',
|
||||
href: '/behavioral-interview/',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Community',
|
||||
items: [
|
||||
{
|
||||
label: 'GitHub',
|
||||
href: 'https://github.com/yangshun/tech-interview-handbook',
|
||||
},
|
||||
{
|
||||
label: 'Discord',
|
||||
href: 'https://discord.gg/usMqNaPczq',
|
||||
},
|
||||
{
|
||||
label: 'Telegram',
|
||||
href: 'https://t.me/techinterviewhandbook',
|
||||
},
|
||||
{
|
||||
label: 'Twitter',
|
||||
href: 'https://twitter.com/techinterviewhb',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'More',
|
||||
items: [
|
||||
{
|
||||
label: 'Grind 75',
|
||||
href: 'https://www.techinterviewhandbook.org/grind75',
|
||||
},
|
||||
{
|
||||
label: 'Front End Interview Handbook',
|
||||
href: 'https://www.frontendinterviewhandbook.com',
|
||||
},
|
||||
{
|
||||
label: 'Contact us',
|
||||
href: 'mailto:contact@techinterviewhandbook.org',
|
||||
},
|
||||
{
|
||||
label: 'Facebook',
|
||||
href: 'https://www.facebook.com/techinterviewhandbook',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
algolia: {
|
||||
appId: 'Y09P1J4IPV',
|
||||
apiKey: 'e12588cbae68d752469921cc46e9cb66',
|
||||
indexName: 'techinterviewhandbook',
|
||||
},
|
||||
docs: {
|
||||
sidebar: {
|
||||
hideable: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
docs: {
|
||||
path: './contents',
|
||||
routeBasePath: '/',
|
||||
sidebarPath: require.resolve('./sidebars.js'),
|
||||
// showLastUpdateAuthor: true,
|
||||
showLastUpdateTime: true,
|
||||
},
|
||||
theme: {
|
||||
customCss: require.resolve('./src/css/custom.css'),
|
||||
},
|
||||
gtag: {
|
||||
trackingID: 'G-9F86L298EX',
|
||||
},
|
||||
blog: {
|
||||
blogSidebarCount: 15,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
'@docusaurus/plugin-google-gtag',
|
||||
{
|
||||
id: 'universal-analytics',
|
||||
trackingID: 'UA-44622716-2',
|
||||
anonymizeIP: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
103
apps/website/experimental/design/README.md
Normal file
103
apps/website/experimental/design/README.md
Normal file
@@ -0,0 +1,103 @@
|
||||
# Design Questions
|
||||
|
||||
## Quality courses
|
||||
|
||||
- ["Grokking the System Design Interview" by Design Gurus](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-system-design-interview) - 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 refer 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 highly recommended many others to use this.
|
||||
- ["Grokking the Advanced System Design Interview" by Design Gurus](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-advanced-system-design-interview) - 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.
|
||||
- ["Best of System Design" package by Design Gurus](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fbundles%3Fbundle_id%3Dbuy-both-system-design-courses) - This bundle allows you to purchase both System Design interview courses by Design Gurus at a discount. Best of all, it's lifetime and not subscription-based.
|
||||
- ["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.
|
||||
|
||||
## Guides
|
||||
|
||||
- [Grokking the System Design Interview](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-system-design-interview)
|
||||
- [Grokking the Advanced System Design Interview](https://designgurus.org/link/kJSIoU?url=https%3A%2F%2Fdesigngurus.org%2Fcourse%3Fcourseid%3Dgrokking-the-advanced-system-design-interview)
|
||||
- https://github.com/donnemartin/system-design-primer
|
||||
- https://github.com/checkcheckzz/system-design-interview
|
||||
- https://github.com/shashank88/system_design
|
||||
- https://gist.github.com/vasanthk/485d1c25737e8e72759f
|
||||
- http://www.puncsky.com/blog/2016/02/14/crack-the-system-design-interview/
|
||||
- https://www.palantir.com/2011/10/how-to-rock-a-systems-design-interview/
|
||||
- http://blog.gainlo.co/index.php/2017/04/13/system-design-interviews-part-ii-complete-guide-google-interview-preparation/
|
||||
- [List of system design videos](https://www.youtube.com/channel/UCn1XnDWhsLS5URXTi5wtFTA)
|
||||
|
||||
## Flow
|
||||
|
||||
#### A. Understand the problem and scope
|
||||
|
||||
- Define the use cases, with interviewer's help.
|
||||
- Suggest additional features.
|
||||
- Remove items that interviewer deems out of scope.
|
||||
- Assume high availability is required, add as a use case.
|
||||
|
||||
#### B. Think about constraints
|
||||
|
||||
- Ask how many requests per month.
|
||||
- Ask how many requests per second (they may volunteer it or make you do the math).
|
||||
- Estimate reads vs. writes percentage.
|
||||
- Keep 80/20 rule in mind when estimating.
|
||||
- How much data written per second.
|
||||
- Total storage required over 5 years.
|
||||
- How much data reads per second.
|
||||
|
||||
#### C. Abstract design
|
||||
|
||||
- Layers (service, data, caching).
|
||||
- Infrastructure: load balancing, messaging.
|
||||
- Rough overview of any key algorithm that drives the service.
|
||||
- Consider bottlenecks and determine solutions.
|
||||
|
||||
Source: https://github.com/jwasham/coding-interview-university#system-design-scalability-data-handling
|
||||
|
||||
## Grading Rubrics
|
||||
|
||||
- Problem Solving - How systematic is your approach to solving the problem step-by-step? Break down a problem into its core components.
|
||||
- Communication - How well do you explain your idea and communicate it with others?
|
||||
- Evaluation - How do you evaluate your system? Are you aware of the trade-offs made? How can you optimize it?
|
||||
- Estimation - How fast does your system need to be? How much space does it need? How much load will it experience?
|
||||
|
||||
## Specific Topics
|
||||
|
||||
- URL Shortener
|
||||
- http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener
|
||||
- http://blog.gainlo.co/index.php/2016/03/08/system-design-interview-question-create-tinyurl-system/
|
||||
- https://www.interviewcake.com/question/python/url-shortener
|
||||
- Collaborative Editor
|
||||
- http://blog.gainlo.co/index.php/2016/03/22/system-design-interview-question-how-to-design-google-docs/
|
||||
- Photo Sharing App
|
||||
- http://blog.gainlo.co/index.php/2016/03/01/system-design-interview-question-create-a-photo-sharing-app/
|
||||
- Social Network Feed
|
||||
- http://blog.gainlo.co/index.php/2016/02/17/system-design-interview-question-how-to-design-twitter-part-1/
|
||||
- http://blog.gainlo.co/index.php/2016/02/24/system-design-interview-question-how-to-design-twitter-part-2/
|
||||
- http://blog.gainlo.co/index.php/2016/03/29/design-news-feed-system-part-1-system-design-interview-questions/
|
||||
- Trending Algorithm
|
||||
- http://blog.gainlo.co/index.php/2016/05/03/how-to-design-a-trending-algorithm-for-twitter/
|
||||
- Facebook Chat
|
||||
- http://blog.gainlo.co/index.php/2016/04/19/design-facebook-chat-function/
|
||||
- Key Value Store
|
||||
- http://blog.gainlo.co/index.php/2016/06/14/design-a-key-value-store-part-i/
|
||||
- http://blog.gainlo.co/index.php/2016/06/21/design-key-value-store-part-ii/
|
||||
- Recommendation System
|
||||
- http://blog.gainlo.co/index.php/2016/05/24/design-a-recommendation-system/
|
||||
- Cache System
|
||||
- http://blog.gainlo.co/index.php/2016/05/17/design-a-cache-system/
|
||||
- E-commerce Website
|
||||
- http://blog.gainlo.co/index.php/2016/08/22/design-ecommerce-website-part/
|
||||
- http://blog.gainlo.co/index.php/2016/08/28/design-ecommerce-website-part-ii/
|
||||
- Web Crawler
|
||||
- http://blog.gainlo.co/index.php/2016/06/29/build-web-crawler/
|
||||
- http://www.makeuseof.com/tag/how-do-search-engines-work-makeuseof-explains/
|
||||
- https://www.quora.com/How-can-I-build-a-web-crawler-from-scratch/answer/Chris-Heller
|
||||
- YouTube
|
||||
- http://blog.gainlo.co/index.php/2016/10/22/design-youtube-part/
|
||||
- http://blog.gainlo.co/index.php/2016/11/04/design-youtube-part-ii/
|
||||
- Hit Counter
|
||||
- http://blog.gainlo.co/index.php/2016/09/12/dropbox-interview-design-hit-counter/
|
||||
- Facebook Graph Search
|
||||
- Design [Lyft Line](https://www.lyft.com/line).
|
||||
- Design a promo code system (with same promo code, randomly generated promo code, and promo code with conditions).
|
||||
- Model a university.
|
||||
- How would you implement Pacman?
|
||||
- Sketch out an implementation of Asteroids.
|
||||
- Implement a spell checker.
|
||||
- Design the rubik cube.
|
||||
- Design a high-level interface to be used for card games (e.g. poker, blackjack etc).
|
||||
107
apps/website/experimental/design/collaborative-editor.md
Normal file
107
apps/website/experimental/design/collaborative-editor.md
Normal file
@@ -0,0 +1,107 @@
|
||||
# Collaborative Document Editor
|
||||
|
||||
## Variants
|
||||
|
||||
- Design Google docs.
|
||||
- Design a collaborative code editor like Coderpad/Codepile.
|
||||
- Design a collaborative markdown editor.
|
||||
|
||||
## Requirements Gathering
|
||||
|
||||
- What is the intended platform?
|
||||
- Web
|
||||
- What features are required?
|
||||
- Creating a document
|
||||
- Editing a document
|
||||
- Sharing a document
|
||||
- Bonus features
|
||||
- Document revisions and reverting
|
||||
- Searching
|
||||
- Commenting
|
||||
- Chatting
|
||||
- Executing code (in the case of code editor)
|
||||
- What is in a document?
|
||||
- Text
|
||||
- Images
|
||||
- Which metrics should we optimize for?
|
||||
- Loading time
|
||||
- Synchronization
|
||||
- Throughput
|
||||
|
||||
## Core Components
|
||||
|
||||
- Front end
|
||||
- WebSockets/long polling for real-time communication between front end and back end.
|
||||
- Back end services behind a reverse proxy.
|
||||
- Reverse proxy will proxy the requests to the right server.
|
||||
- Split into a few services for different purposes.
|
||||
- The benefit of this is that each service can use different languages that best suits its purpose.
|
||||
- API servers for non-collaborative features and endpoints.
|
||||
- Ruby/Rails/Django for the server that deals with CRUD operations on data models where performance is not that crucial.
|
||||
- WebSocket servers for handling document edits and publishing updates to listeners.
|
||||
- Possibly Node/Golang for WebSocket server which will need high performance as updates are frequent.
|
||||
- Task queue to persist document updates to the database.
|
||||
- ELB in front of back end servers.
|
||||
- MySQL database.
|
||||
- S3 and CDN for images.
|
||||
|
||||
## Data Modeling
|
||||
|
||||
- What kind of database to use?
|
||||
- Data is quite structured. Would go with SQL.
|
||||
- Design the necessary tables, its columns and its relations.
|
||||
- `users`
|
||||
- `id`
|
||||
- `name`
|
||||
- `document`
|
||||
- `id`
|
||||
- `owner_id`
|
||||
- `permissions`
|
||||
- `id`
|
||||
- `name`
|
||||
- `document_permissions`
|
||||
- `id`
|
||||
- `document_id`
|
||||
- `user_id`
|
||||
|
||||
## Collaborative Editing - Client
|
||||
|
||||
- Upon loading of the page and document, the client should connect to the WebSocket server over the WebSocket protocol `ws://`.
|
||||
- Upon connection, perform a time sync with the server, possibly via Network Time Protocol (NTP).
|
||||
- The most straightforward way is to send the whole updated document content to the back end, and all users currently viewing the document will receive the updated document. However, there are a few problems with this approach:
|
||||
- Race condition. If two users editing the document at the same time, the last one to edit will overwrite the changes by the previous user. One workaround is to lock the document when a user is currently editing it, but that will not make it real-time collaborative.
|
||||
- A large payload (the whole document) is being sent to servers and published to users on each change, and the user is likely to already have most of the content. A lot of redundant data being sent.
|
||||
- A feasible approach would be to use operational transforms and send just the action deltas to the back end. The back end publishes the action deltas to the listeners. What is considered an action delta?
|
||||
- (a) Changing a character/word, (b) inserting a character/word/image, (c) deleting a character/word.
|
||||
- With this approach, the payload will contain only small amount of data, such as (a) type of change, (b) character/word, (c) position in document: line/column, (d) timestamp. Why is the timestamp needed? Read on to find out.
|
||||
- Updates can also be throttled and batched, to avoid flooding the web server with requests. For example, if a user inserts a
|
||||
|
||||
## Back End
|
||||
|
||||
The back end is split into a few portions: WebSocket server for receiving and broadcasting document updates, CRUD server for reading and writing non-document-related data, and a task queue for persistence of the document.
|
||||
|
||||
## WebSocket Server
|
||||
|
||||
- Languages and frameworks that support async requests and non-blocking I/O will be suitable for the collaborative editor server. Node and Golang comes to my mind.
|
||||
- However, the WebSocket server is not stateless, so is it not that straightforward to scale horizontally. One approach would be for a Load Balancer to use Redis to maintain a map of the client to the WebSocket server instance IP, such that subsequent requests from the same client will be routed to the same server.
|
||||
- Each document corresponds to a room (more of namespace). Users can subscribe to the events happening within a room.
|
||||
- When a action delta is being received, blast it out to the listeners within the room and add it to the task queue.
|
||||
|
||||
## CRUD Server
|
||||
|
||||
- Provides APIs for reading and writing non-document-related data, such as users, permissions.
|
||||
|
||||
## Task Queue + Worker Service
|
||||
|
||||
- Worker service retrieves messages from the task queue and writes the updated documents to the database in an async fashion.
|
||||
- Batch the actions together and perform one larger write that consists of multiple actions. For example, instead of persisting to the database once per addition of a word, combine these additions and write them into the database at once.
|
||||
- Publish the save completion event to the WebSocket server to be published to the listeners, informing that the latest version of the document is being saved.
|
||||
- Benefit of using a task queue is that as the amount of tasks in the queue goes up, we can scale up the number of worker services to clear the backlog of work faster.
|
||||
|
||||
## Document Persistence
|
||||
|
||||
TODO
|
||||
|
||||
###### References
|
||||
|
||||
- http://blog.gainlo.co/index.php/2016/03/22/system-design-interview-question-how-to-design-google-docs/
|
||||
164
apps/website/experimental/design/news-feed.md
Normal file
164
apps/website/experimental/design/news-feed.md
Normal file
@@ -0,0 +1,164 @@
|
||||
# News Feed
|
||||
|
||||
## Variants
|
||||
|
||||
- Design Facebook news feed.
|
||||
- Design Twitter news feed.
|
||||
- Design Quora feed.
|
||||
- Design Instagram feed.
|
||||
|
||||
## Requirements Gathering
|
||||
|
||||
- What is the intended platform?
|
||||
- Mobile (mobile web or native)? Web? Desktop?
|
||||
- What features are required?
|
||||
- CRUD posts.
|
||||
- Commenting on posts.
|
||||
- Sharing posts.
|
||||
- Trending posts?
|
||||
- Tag people?
|
||||
- Hashtags?
|
||||
- What is in a news feed post?
|
||||
- Author.
|
||||
- Content.
|
||||
- Media.
|
||||
- Tags?
|
||||
- Hashtags?
|
||||
- Comments/Replies.
|
||||
- Operations:
|
||||
- CRUD
|
||||
- Commenting/replying to a post.
|
||||
- What is in a news feed?
|
||||
- Sequence of posts.
|
||||
- Query pattern: query for a user's ranked news feed.
|
||||
- Operations:
|
||||
- Append - Fetch more posts.
|
||||
- Delete - I don't want to see this.
|
||||
- Which metrics should we optimize for?
|
||||
- User retention.
|
||||
- Ads revenue.
|
||||
- Fast loading time.
|
||||
- Bandwidth.
|
||||
- Server costs.
|
||||
|
||||
## Core Components
|
||||
|
||||
TODO
|
||||
|
||||
## Data modeling
|
||||
|
||||
- What kind of database to use?
|
||||
- Data is quite structured. Would go with SQL.
|
||||
- Design the necessary tables, its columns and its relations.
|
||||
- `users`
|
||||
- `posts`
|
||||
- `likes`
|
||||
- `follows`
|
||||
- `comments`
|
||||
|
||||
> There are two basic objects: user and feed. For user object, we can store userID, name, registration date and so on so forth. And for feed object, there are feedId, feedType, content, metadata etc., which should support images and videos as well.
|
||||
>
|
||||
> If we are using a relational database, we also need to model two relations: user-feed relation and friend relation. The former is pretty straightforward. We can create a user-feed table that stores userID and corresponding feedID. For a single user, it can contain multiple entries if he has published many feeds.
|
||||
>
|
||||
> For friend relation, adjacency list is one of the most common approaches. If we see all the users as nodes in a giant graph, edges that connect nodes denote friend relation. We can use a friend table that contains two userIDs in each entry to model the edge (friend relation). By doing this, most operations are quite convenient like fetch all friends of a user, check if two people are friends.
|
||||
>
|
||||
> The system will first get all userIDs of friends from friend table. Then it fetches all feedIDs for each friend from user-feed table. Finally, feed content is fetched based on feedID from feed table. You can see that we need to perform 3 joins, which can affect performance.
|
||||
>
|
||||
> A common optimization is to store feed content together with feedID in user-feed table so that we don't need to join the feed table any more. This approach is called denormalization, which means by adding redundant data, we can optimize the read performance (reducing the number of joins).
|
||||
>
|
||||
> The disadvantages are obvious:
|
||||
>
|
||||
> - Data redundancy. We are storing redundant data, which occupies storage space (classic time-space trade-off).
|
||||
> - Data consistency. Whenever we update a feed, we need to update both feed table and user-feed table. Otherwise, there is data inconsistency. This increases the complexity of the system.
|
||||
> - Remember that there's no one approach always better than the other (normalization vs denormalization). It's a matter of whether you want to optimize for read or write.
|
||||
|
||||
## Feed Display
|
||||
|
||||
- The most straightforward way is to fetch posts from all the people you follow and render them sorted by time.
|
||||
- There can be many posts to fetch. How many posts should you fetch?
|
||||
- What are the pagination approaches and the pros and cons of each approach?
|
||||
- Offset by page size
|
||||
- Offset by time
|
||||
- What data should the post contain when you initially fetch them?
|
||||
- Lazy loading approach for loading associated data: media, comments, people who liked the post.
|
||||
- Media
|
||||
- If the post contains media such as images and videos, how should they be handled? Should they be loaded on the spot?
|
||||
- A better way would be to fetch images only when they are about to enter the viewport.
|
||||
- Videos should not autoplay. Only fetch the thumbnail for the video, and only play the video when user clicks play.
|
||||
- If the content is being refetched, the media should be cached and not fetched over the wire again. This is especially important on mobile connections where data can be expensive.
|
||||
- Comments
|
||||
- Should you fetch all the comments for a post? For posts by celebrities, they can contain a few hundred or thousand comments.
|
||||
- Maybe fetch the top few comments and display them under the post, and the user is given the choice to "show all comments".
|
||||
- How does the user request for new content?
|
||||
- Infinite scrolling.
|
||||
- User has to tap next page.
|
||||
|
||||
## Feed Ranking
|
||||
|
||||
- First select features/signals that are relevant and then figure out how to combine them to calculate a final score.
|
||||
- How do you show the relevant posts that the user is interested in?
|
||||
- Chronological - While a chronological approach works, it may not be the most engaging approach. For example, if a person posts 30 times within the last hour, his followers will have their news feed clogged up with his posts. Maybe set a cap on the number of time a person's posts can appear within the feed.
|
||||
- Popularity - How many likes and comments does the post have? Does the user usually like posts by that person?
|
||||
- How do you determine which are the more important posts? A user might be more interested in a few-hour old post from a good friend than a very recent post from an acquaintance.
|
||||
- A common strategy is to calculate a post score based on various features and rank posts by its score.
|
||||
- Prior to 2013, Facebook was using the [EdgeRank](https://www.wikiwand.com/en/EdgeRank) algorithm to determine what articles should be displayed in a user's News Feed.
|
||||
- Edge Rank basically is using three signals: affinity score, edge weight and time decay.
|
||||
- Affinity score (u) - For each news feed, affinity score evaluates how close you are with this user. For instance, you are more likely to care about feed from your close friends instead of someone you just met once.
|
||||
- Edge weight (e) - Edge weight basically reflects importance of each edge. For instance, comments are worth more than likes.
|
||||
- Time decay (d) - The older the story, the less likely users find it interesting.
|
||||
- Affinity score
|
||||
- Various factors can be used to reflect how close two people are. First of all, explicit interactions like comment, like, tag, share, click etc. are strong signals we should use. Apparently, each type of interaction should have different weight. For instance, comments should be worth much more than likes.
|
||||
- Secondly, we should also track the time factor. Perhaps you used to interact with a friend quite a lot, but less frequent recently. In this case, we should lower the affinity score. So for each interaction, we should also put the time decay factor.
|
||||
- A good ranking system can improve some core metrics - user retention, ads revenue, etc.
|
||||
|
||||
## Feed Publishing
|
||||
|
||||
TODO. Refer to http://blog.gainlo.co/index.php/2016/04/05/design-news-feed-system-part-2/.
|
||||
|
||||
## Additional Features
|
||||
|
||||
#### Tagging feature
|
||||
|
||||
- Have a `tags` table that stores the relation between a post and the people tagged in it.
|
||||
|
||||
#### Sharing feature
|
||||
|
||||
- Add a column to `posts` table called `original_post_id`.
|
||||
- What should happen when the original post is deleted?
|
||||
- The shared `posts` have to be deleted too.
|
||||
|
||||
#### Notifications feature
|
||||
|
||||
- When should notifications happen?
|
||||
- Can the user subscribe to only certain types of notifications?
|
||||
|
||||
#### Trending feature
|
||||
|
||||
- What constitutes trending? What signals would you look at? What weight would you give to each signal?
|
||||
- Most frequent hashtags over the last N hours.
|
||||
- Hottest search queries.
|
||||
- Fetch the recent most popular feeds and extract some common words or phrases.
|
||||
|
||||
#### Search feature
|
||||
|
||||
- How would you index the data?
|
||||
|
||||
## Scalability
|
||||
|
||||
- Master-slave replication.
|
||||
- Write to master database and read from replica databases/in-memory data store.
|
||||
- Post contents are being read more than they are updated. It is acceptable to have a slight lag between a user updating a post and followers seeing the updated content. Tweets are not even editable.
|
||||
- Data for real-time queries should be in memory, disk is for writes only.
|
||||
- Pre-computation offline.
|
||||
- Tracking number of likes and comments.
|
||||
- Expensive to do a `COUNT` on the `likes` and `comments` for a post.
|
||||
- Use Redis/Memcached for keeping track of how many likes/comments a post has. Increment when there's new activity, decrement when someone unlikes/deletes the comment.
|
||||
- Load balancer in front of your API servers.
|
||||
- Partitioning the data.
|
||||
|
||||
###### References
|
||||
|
||||
- [Design News Feed System (Part 1)](http://blog.gainlo.co/index.php/2016/03/29/design-news-feed-system-part-1-system-design-interview-questions/)
|
||||
- [Design News Feed System (Part 1)](http://blog.gainlo.co/index.php/2016/04/05/design-news-feed-system-part-2/)
|
||||
- [Etsy Activity Feeds Architecture](https://www.slideshare.net/danmckinley/etsy-activity-feeds-architecture)
|
||||
- [Big Data in Real-Time at Twitter](https://www.slideshare.net/nkallen/q-con-3770885)
|
||||
5
apps/website/experimental/design/search-engine.md
Normal file
5
apps/website/experimental/design/search-engine.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Search Engine
|
||||
|
||||
###### References
|
||||
|
||||
- [How Do Search Engines Work?](http://www.makeuseof.com/tag/how-do-search-engines-work-makeuseof-explains/)
|
||||
61
apps/website/experimental/domain/async-loading/index.html
Normal file
61
apps/website/experimental/domain/async-loading/index.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Helvetica', sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<div id="chapters">
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(() => {
|
||||
const DOM = {
|
||||
$chapters: document.getElementById('chapters'),
|
||||
};
|
||||
const URL = 'https://raw.githubusercontent.com/googlesamples/web-fundamentals/gh-pages/fundamentals/getting-started/primers';
|
||||
|
||||
function getJSON(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = new XMLHttpRequest();
|
||||
req.open('GET', url);
|
||||
req.onload = () => {
|
||||
if (req.status === 200) {
|
||||
resolve(JSON.parse(req.response));
|
||||
return;
|
||||
}
|
||||
reject(req.responseText);
|
||||
}
|
||||
req.onerror = (err) => {
|
||||
reject(err);
|
||||
}
|
||||
req.send();
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
getJSON(`${URL}/story.json`).then(story => {
|
||||
const $heading = document.createRange().createContextualFragment(story.heading);
|
||||
DOM.$chapters.before($heading);
|
||||
return Promise.all(story.chapterUrls.map((url, index) => {
|
||||
return getJSON(`${URL}/${url}`);
|
||||
}));
|
||||
}).then(chapters => {
|
||||
const $chapters = document.createDocumentFragment();
|
||||
chapters.forEach(chapter => {
|
||||
$chapters.appendChild(document.createRange().createContextualFragment(chapter.html));
|
||||
});
|
||||
DOM.$chapters.appendChild($chapters);
|
||||
}).catch(err => {
|
||||
console.warn(err);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
7
apps/website/experimental/domain/databases.md
Normal file
7
apps/website/experimental/domain/databases.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Databases
|
||||
|
||||
## General
|
||||
|
||||
- How should you store passwords in a database?
|
||||
- http://www.geeksforgeeks.org/store-password-database/
|
||||
- https://nakedsecurity.sophos.com/2013/11/20/serious-security-how-to-store-your-users-passwords-safely/
|
||||
5
apps/website/experimental/domain/networking.md
Normal file
5
apps/website/experimental/domain/networking.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Networking
|
||||
|
||||
- Given an IPv4 IP address p and an integer n, return a list of CIDR strings that most succinctly represents the range of IP addresses from p to (p + n).
|
||||
- Describe what happens when you enter a url in the web browser.
|
||||
- Define UDP/TCP and give an example of both.
|
||||
677
apps/website/experimental/domain/pagination-sorting/data.js
Normal file
677
apps/website/experimental/domain/pagination-sorting/data.js
Normal file
@@ -0,0 +1,677 @@
|
||||
const data = [
|
||||
{
|
||||
_id: '591ad7e2d1b6119887420af5',
|
||||
age: 36,
|
||||
name: 'Salas Mccarthy',
|
||||
gender: 'male',
|
||||
company: 'MAKINGWAY',
|
||||
email: 'salasmccarthy@makingway.com',
|
||||
phone: '+1 (905) 546-3931',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2918b0ba1231b582d',
|
||||
age: 29,
|
||||
name: 'Jodi Graham',
|
||||
gender: 'female',
|
||||
company: 'BITREX',
|
||||
email: 'jodigraham@bitrex.com',
|
||||
phone: '+1 (861) 596-2691',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2bc19d181dcb64d57',
|
||||
age: 34,
|
||||
name: 'Hollie Hardin',
|
||||
gender: 'female',
|
||||
company: 'ZENSURE',
|
||||
email: 'holliehardin@zensure.com',
|
||||
phone: '+1 (822) 410-2433',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e224d2fa7216132561',
|
||||
age: 26,
|
||||
name: 'Bullock Cole',
|
||||
gender: 'male',
|
||||
company: 'ZILPHUR',
|
||||
email: 'bullockcole@zilphur.com',
|
||||
phone: '+1 (839) 563-3350',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e206c3fb3043ccf8a8',
|
||||
age: 30,
|
||||
name: 'Peterson Mosley',
|
||||
gender: 'male',
|
||||
company: 'MOBILDATA',
|
||||
email: 'petersonmosley@mobildata.com',
|
||||
phone: '+1 (974) 547-3461',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e20a180de908b0960e',
|
||||
age: 34,
|
||||
name: 'Lucille Jackson',
|
||||
gender: 'female',
|
||||
company: 'KINETICUT',
|
||||
email: 'lucillejackson@kineticut.com',
|
||||
phone: '+1 (845) 443-3594',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2768b0cf4837ecf35',
|
||||
age: 40,
|
||||
name: 'Cooper Leonard',
|
||||
gender: 'male',
|
||||
company: 'CHORIZON',
|
||||
email: 'cooperleonard@chorizon.com',
|
||||
phone: '+1 (817) 418-2290',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e270a640cf8f8a3e44',
|
||||
age: 27,
|
||||
name: 'Iris Shepherd',
|
||||
gender: 'female',
|
||||
company: 'IDEALIS',
|
||||
email: 'irisshepherd@idealis.com',
|
||||
phone: '+1 (858) 599-3628',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e222ddd244aaba0315',
|
||||
age: 31,
|
||||
name: 'Oneil Head',
|
||||
gender: 'male',
|
||||
company: 'LIMOZEN',
|
||||
email: 'oneilhead@limozen.com',
|
||||
phone: '+1 (894) 440-3396',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2d36847b5e648587b',
|
||||
age: 28,
|
||||
name: 'Swanson Singleton',
|
||||
gender: 'male',
|
||||
company: 'NSPIRE',
|
||||
email: 'swansonsingleton@nspire.com',
|
||||
phone: '+1 (817) 510-2480',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2b78092f9fb866779',
|
||||
age: 37,
|
||||
name: 'Sutton Odom',
|
||||
gender: 'male',
|
||||
company: 'GLUKGLUK',
|
||||
email: 'suttonodom@glukgluk.com',
|
||||
phone: '+1 (961) 424-2812',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e222736aa66a9b35cc',
|
||||
age: 31,
|
||||
name: 'Chandler Kirk',
|
||||
gender: 'male',
|
||||
company: 'EWAVES',
|
||||
email: 'chandlerkirk@ewaves.com',
|
||||
phone: '+1 (902) 524-3712',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2ac3f9abecd5175a7',
|
||||
age: 28,
|
||||
name: 'Gentry Stanley',
|
||||
gender: 'male',
|
||||
company: 'GINK',
|
||||
email: 'gentrystanley@gink.com',
|
||||
phone: '+1 (878) 592-2331',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2f79787dc605d61fb',
|
||||
age: 28,
|
||||
name: 'Paulette Guthrie',
|
||||
gender: 'female',
|
||||
company: 'SEQUITUR',
|
||||
email: 'pauletteguthrie@sequitur.com',
|
||||
phone: '+1 (820) 473-2926',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2ff61553783737bc0',
|
||||
age: 37,
|
||||
name: 'Lesley Nash',
|
||||
gender: 'female',
|
||||
company: 'MELBACOR',
|
||||
email: 'lesleynash@melbacor.com',
|
||||
phone: '+1 (849) 414-2115',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e26f9c3fc95fa8e6f1',
|
||||
age: 22,
|
||||
name: 'Frye Oneil',
|
||||
gender: 'male',
|
||||
company: 'OVERPLEX',
|
||||
email: 'fryeoneil@overplex.com',
|
||||
phone: '+1 (999) 412-2403',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2eee8b7cd857a29d0',
|
||||
age: 40,
|
||||
name: 'Christina Zamora',
|
||||
gender: 'female',
|
||||
company: 'REPETWIRE',
|
||||
email: 'christinazamora@repetwire.com',
|
||||
phone: '+1 (860) 504-3885',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2be93544c81761053',
|
||||
age: 25,
|
||||
name: 'Earlene Dunn',
|
||||
gender: 'female',
|
||||
company: 'PHARMEX',
|
||||
email: 'earlenedunn@pharmex.com',
|
||||
phone: '+1 (831) 582-2974',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2cb672de927940ef4',
|
||||
age: 25,
|
||||
name: 'Hoffman Pittman',
|
||||
gender: 'male',
|
||||
company: 'ENOMEN',
|
||||
email: 'hoffmanpittman@enomen.com',
|
||||
phone: '+1 (882) 420-3186',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2aabaae50d75c21a3',
|
||||
age: 35,
|
||||
name: 'Wilson Tran',
|
||||
gender: 'male',
|
||||
company: 'CAXT',
|
||||
email: 'wilsontran@caxt.com',
|
||||
phone: '+1 (842) 529-3085',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2bdd6104be85bdd87',
|
||||
age: 22,
|
||||
name: 'Hensley Hawkins',
|
||||
gender: 'male',
|
||||
company: 'LUDAK',
|
||||
email: 'hensleyhawkins@ludak.com',
|
||||
phone: '+1 (902) 566-3308',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e24796cbdc0eacb6c0',
|
||||
age: 36,
|
||||
name: 'Gray Schultz',
|
||||
gender: 'male',
|
||||
company: 'EBIDCO',
|
||||
email: 'grayschultz@ebidco.com',
|
||||
phone: '+1 (910) 532-2845',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e204425cc3b121279a',
|
||||
age: 25,
|
||||
name: 'Odonnell Livingston',
|
||||
gender: 'male',
|
||||
company: 'ANOCHA',
|
||||
email: 'odonnelllivingston@anocha.com',
|
||||
phone: '+1 (991) 422-2754',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2997ac59b446d3a30',
|
||||
age: 36,
|
||||
name: 'Shelton Lindsay',
|
||||
gender: 'male',
|
||||
company: 'DENTREX',
|
||||
email: 'sheltonlindsay@dentrex.com',
|
||||
phone: '+1 (899) 567-2928',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2646dad2ff456b035',
|
||||
age: 40,
|
||||
name: 'Mcclain Larson',
|
||||
gender: 'male',
|
||||
company: 'GENMOM',
|
||||
email: 'mcclainlarson@genmom.com',
|
||||
phone: '+1 (934) 508-3477',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e21e908e847ee6d3ea',
|
||||
age: 27,
|
||||
name: 'Miranda Branch',
|
||||
gender: 'female',
|
||||
company: 'ROCKYARD',
|
||||
email: 'mirandabranch@rockyard.com',
|
||||
phone: '+1 (989) 446-2387',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2d7905d2fcaa1ce18',
|
||||
age: 36,
|
||||
name: 'Valencia Moreno',
|
||||
gender: 'male',
|
||||
company: 'KIOSK',
|
||||
email: 'valenciamoreno@kiosk.com',
|
||||
phone: '+1 (807) 449-2626',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e245e3c4ce18a92054',
|
||||
age: 40,
|
||||
name: 'Witt Leblanc',
|
||||
gender: 'male',
|
||||
company: 'ENERSAVE',
|
||||
email: 'wittleblanc@enersave.com',
|
||||
phone: '+1 (809) 491-3886',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e27f2c70583d1cf34f',
|
||||
age: 32,
|
||||
name: 'Glover Mccoy',
|
||||
gender: 'male',
|
||||
company: 'BYTREX',
|
||||
email: 'glovermccoy@bytrex.com',
|
||||
phone: '+1 (928) 470-2426',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e22768012595c933c9',
|
||||
age: 25,
|
||||
name: 'Billie Dunlap',
|
||||
gender: 'female',
|
||||
company: 'INQUALA',
|
||||
email: 'billiedunlap@inquala.com',
|
||||
phone: '+1 (903) 415-2136',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e22df8d07559a29904',
|
||||
age: 21,
|
||||
name: 'Bridget Hill',
|
||||
gender: 'female',
|
||||
company: 'TRIBALOG',
|
||||
email: 'bridgethill@tribalog.com',
|
||||
phone: '+1 (954) 461-3390',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e201b2bddbc81ae05e',
|
||||
age: 30,
|
||||
name: 'Dawson Clements',
|
||||
gender: 'male',
|
||||
company: 'EURON',
|
||||
email: 'dawsonclements@euron.com',
|
||||
phone: '+1 (926) 570-3444',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2c2aeb820e77c1d9a',
|
||||
age: 31,
|
||||
name: 'Valdez Johnson',
|
||||
gender: 'male',
|
||||
company: 'RETRACK',
|
||||
email: 'valdezjohnson@retrack.com',
|
||||
phone: '+1 (841) 506-2428',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2370ff047048bd688',
|
||||
age: 31,
|
||||
name: 'Nichole Dickerson',
|
||||
gender: 'female',
|
||||
company: 'NEOCENT',
|
||||
email: 'nicholedickerson@neocent.com',
|
||||
phone: '+1 (945) 437-3591',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2b77affba5a8f8603',
|
||||
age: 34,
|
||||
name: 'Madden Weaver',
|
||||
gender: 'male',
|
||||
company: 'VERBUS',
|
||||
email: 'maddenweaver@verbus.com',
|
||||
phone: '+1 (810) 598-3145',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e21e692cc8247b1d83',
|
||||
age: 26,
|
||||
name: 'Larsen Benson',
|
||||
gender: 'male',
|
||||
company: 'ISOSURE',
|
||||
email: 'larsenbenson@isosure.com',
|
||||
phone: '+1 (890) 435-2219',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2de06284f2d2a8d19',
|
||||
age: 37,
|
||||
name: 'Barnes Gaines',
|
||||
gender: 'male',
|
||||
company: 'RODEOCEAN',
|
||||
email: 'barnesgaines@rodeocean.com',
|
||||
phone: '+1 (824) 484-2693',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e20d9d8224dfbd292f',
|
||||
age: 28,
|
||||
name: 'Pacheco Landry',
|
||||
gender: 'male',
|
||||
company: 'METROZ',
|
||||
email: 'pachecolandry@metroz.com',
|
||||
phone: '+1 (813) 525-3821',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2c5348da6a981a148',
|
||||
age: 21,
|
||||
name: 'Richard Alexander',
|
||||
gender: 'male',
|
||||
company: 'GADTRON',
|
||||
email: 'richardalexander@gadtron.com',
|
||||
phone: '+1 (911) 513-3007',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2ca9ef31ba3b67d4f',
|
||||
age: 22,
|
||||
name: 'Stone Campos',
|
||||
gender: 'male',
|
||||
company: 'TETAK',
|
||||
email: 'stonecampos@tetak.com',
|
||||
phone: '+1 (879) 440-3672',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2ff5a9796c8470151',
|
||||
age: 31,
|
||||
name: 'Walter Randall',
|
||||
gender: 'male',
|
||||
company: 'EQUITAX',
|
||||
email: 'walterrandall@equitax.com',
|
||||
phone: '+1 (927) 563-3777',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e272c6b6c1241b3a4a',
|
||||
age: 27,
|
||||
name: 'Copeland Compton',
|
||||
gender: 'male',
|
||||
company: 'MAXIMIND',
|
||||
email: 'copelandcompton@maximind.com',
|
||||
phone: '+1 (829) 599-2574',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2220c6caa9e2c444d',
|
||||
age: 30,
|
||||
name: 'Lorie Irwin',
|
||||
gender: 'female',
|
||||
company: 'ELPRO',
|
||||
email: 'lorieirwin@elpro.com',
|
||||
phone: '+1 (938) 584-2368',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2942d603032f1ebda',
|
||||
age: 35,
|
||||
name: 'Buck Roth',
|
||||
gender: 'male',
|
||||
company: 'COMTRACT',
|
||||
email: 'buckroth@comtract.com',
|
||||
phone: '+1 (830) 585-3168',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2c23efccd2fcd5b2e',
|
||||
age: 31,
|
||||
name: 'Mamie Robinson',
|
||||
gender: 'female',
|
||||
company: 'ZOMBOID',
|
||||
email: 'mamierobinson@zomboid.com',
|
||||
phone: '+1 (845) 481-3222',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e285109fadbf0f9c01',
|
||||
age: 33,
|
||||
name: 'Bryan Stone',
|
||||
gender: 'male',
|
||||
company: 'PODUNK',
|
||||
email: 'bryanstone@podunk.com',
|
||||
phone: '+1 (971) 469-3832',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e25abc328c2cc42283',
|
||||
age: 37,
|
||||
name: 'Benson Lyons',
|
||||
gender: 'male',
|
||||
company: 'FUTURITY',
|
||||
email: 'bensonlyons@futurity.com',
|
||||
phone: '+1 (964) 536-3522',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e28fa81611cdf5066a',
|
||||
age: 37,
|
||||
name: 'Sally Finley',
|
||||
gender: 'female',
|
||||
company: 'ZYTRAC',
|
||||
email: 'sallyfinley@zytrac.com',
|
||||
phone: '+1 (953) 506-2428',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e271c5882aa5452601',
|
||||
age: 26,
|
||||
name: 'Callahan Mckee',
|
||||
gender: 'male',
|
||||
company: 'ACCUPRINT',
|
||||
email: 'callahanmckee@accuprint.com',
|
||||
phone: '+1 (842) 400-3570',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2275e787c5d9eea26',
|
||||
age: 25,
|
||||
name: 'Ines Hamilton',
|
||||
gender: 'female',
|
||||
company: 'PROSURE',
|
||||
email: 'ineshamilton@prosure.com',
|
||||
phone: '+1 (976) 485-2663',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2d8790e386b671ec6',
|
||||
age: 38,
|
||||
name: 'Mcknight Abbott',
|
||||
gender: 'male',
|
||||
company: 'MAXEMIA',
|
||||
email: 'mcknightabbott@maxemia.com',
|
||||
phone: '+1 (960) 600-3920',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2a1cae1e4f17d8db2',
|
||||
age: 28,
|
||||
name: 'Tanisha Ross',
|
||||
gender: 'female',
|
||||
company: 'SYNKGEN',
|
||||
email: 'tanishaross@synkgen.com',
|
||||
phone: '+1 (920) 502-3204',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2f816fd6848bc03a3',
|
||||
age: 22,
|
||||
name: 'Pam Webb',
|
||||
gender: 'female',
|
||||
company: 'VALREDA',
|
||||
email: 'pamwebb@valreda.com',
|
||||
phone: '+1 (926) 442-2683',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e208585adb332ac653',
|
||||
age: 29,
|
||||
name: 'Bobbi Mays',
|
||||
gender: 'female',
|
||||
company: 'PARLEYNET',
|
||||
email: 'bobbimays@parleynet.com',
|
||||
phone: '+1 (940) 577-3487',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2f4b29cbd1744b14e',
|
||||
age: 27,
|
||||
name: 'Snider Sandoval',
|
||||
gender: 'male',
|
||||
company: 'GRONK',
|
||||
email: 'snidersandoval@gronk.com',
|
||||
phone: '+1 (903) 526-2655',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e23a3f54209ec9deba',
|
||||
age: 33,
|
||||
name: 'Fitzpatrick Weiss',
|
||||
gender: 'male',
|
||||
company: 'MICROLUXE',
|
||||
email: 'fitzpatrickweiss@microluxe.com',
|
||||
phone: '+1 (894) 494-2135',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e229d21e1b7723c044',
|
||||
age: 27,
|
||||
name: 'Kimberly Brown',
|
||||
gender: 'female',
|
||||
company: 'SPACEWAX',
|
||||
email: 'kimberlybrown@spacewax.com',
|
||||
phone: '+1 (832) 481-2926',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e247e285f0c563ac94',
|
||||
age: 20,
|
||||
name: 'Fisher Kent',
|
||||
gender: 'male',
|
||||
company: 'ORBIN',
|
||||
email: 'fisherkent@orbin.com',
|
||||
phone: '+1 (962) 523-3956',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e274439c6eb52e99df',
|
||||
age: 26,
|
||||
name: 'Arlene Carroll',
|
||||
gender: 'female',
|
||||
company: 'ELITA',
|
||||
email: 'arlenecarroll@elita.com',
|
||||
phone: '+1 (998) 497-3751',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e271852e5766fad809',
|
||||
age: 22,
|
||||
name: 'Tamra Spence',
|
||||
gender: 'female',
|
||||
company: 'ARTWORLDS',
|
||||
email: 'tamraspence@artworlds.com',
|
||||
phone: '+1 (963) 516-2492',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e28c9165c4372744f7',
|
||||
age: 29,
|
||||
name: 'Alice Goodman',
|
||||
gender: 'female',
|
||||
company: 'ZILLIDIUM',
|
||||
email: 'alicegoodman@zillidium.com',
|
||||
phone: '+1 (829) 577-2972',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2c2a9121f713f15c3',
|
||||
age: 27,
|
||||
name: 'Clay Washington',
|
||||
gender: 'male',
|
||||
company: 'EXOSTREAM',
|
||||
email: 'claywashington@exostream.com',
|
||||
phone: '+1 (926) 460-3699',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2c99d41ce0347ac8f',
|
||||
age: 38,
|
||||
name: 'Navarro Walsh',
|
||||
gender: 'male',
|
||||
company: 'ILLUMITY',
|
||||
email: 'navarrowalsh@illumity.com',
|
||||
phone: '+1 (896) 564-3270',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e25e7c6ff0785d1337',
|
||||
age: 22,
|
||||
name: 'Alexandra Hughes',
|
||||
gender: 'female',
|
||||
company: 'TASMANIA',
|
||||
email: 'alexandrahughes@tasmania.com',
|
||||
phone: '+1 (977) 509-3599',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2acb8a5785b6fd512',
|
||||
age: 40,
|
||||
name: 'Vonda Oliver',
|
||||
gender: 'female',
|
||||
company: 'NEPTIDE',
|
||||
email: 'vondaoliver@neptide.com',
|
||||
phone: '+1 (836) 595-2260',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e20543a9fc7bc33515',
|
||||
age: 36,
|
||||
name: 'Christa Nixon',
|
||||
gender: 'female',
|
||||
company: 'GLASSTEP',
|
||||
email: 'christanixon@glasstep.com',
|
||||
phone: '+1 (966) 551-2149',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e21b8e73ba4dbf7c9a',
|
||||
age: 34,
|
||||
name: 'Weber Hurst',
|
||||
gender: 'male',
|
||||
company: 'SLUMBERIA',
|
||||
email: 'weberhurst@slumberia.com',
|
||||
phone: '+1 (943) 516-3449',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e282b9cb56357b42db',
|
||||
age: 27,
|
||||
name: 'Rasmussen Kramer',
|
||||
gender: 'male',
|
||||
company: 'MUSIX',
|
||||
email: 'rasmussenkramer@musix.com',
|
||||
phone: '+1 (891) 553-3264',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2287c587e3a04e80c',
|
||||
age: 30,
|
||||
name: 'Mayra Beasley',
|
||||
gender: 'female',
|
||||
company: 'BRAINCLIP',
|
||||
email: 'mayrabeasley@brainclip.com',
|
||||
phone: '+1 (958) 576-2642',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e26245135989367fa8',
|
||||
age: 20,
|
||||
name: 'Nunez Ortiz',
|
||||
gender: 'male',
|
||||
company: 'KYAGURU',
|
||||
email: 'nunezortiz@kyaguru.com',
|
||||
phone: '+1 (906) 591-3563',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e23248cee3b84bde40',
|
||||
age: 39,
|
||||
name: 'Michael Foreman',
|
||||
gender: 'male',
|
||||
company: 'DANCITY',
|
||||
email: 'michaelforeman@dancity.com',
|
||||
phone: '+1 (848) 400-3539',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e23ae236a1d59d07ee',
|
||||
age: 36,
|
||||
name: 'Virgie Wheeler',
|
||||
gender: 'female',
|
||||
company: 'XIIX',
|
||||
email: 'virgiewheeler@xiix.com',
|
||||
phone: '+1 (831) 400-2814',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2d8b9e3c0c31d770d',
|
||||
age: 31,
|
||||
name: 'Levy Hoover',
|
||||
gender: 'male',
|
||||
company: 'CANDECOR',
|
||||
email: 'levyhoover@candecor.com',
|
||||
phone: '+1 (843) 428-2780',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e2badb7200ca06a483',
|
||||
age: 21,
|
||||
name: 'Battle Stanton',
|
||||
gender: 'male',
|
||||
company: 'CALCULA',
|
||||
email: 'battlestanton@calcula.com',
|
||||
phone: '+1 (861) 522-3951',
|
||||
},
|
||||
{
|
||||
_id: '591ad7e27fd1a4455ccf406c',
|
||||
age: 24,
|
||||
name: 'Church Lynn',
|
||||
gender: 'male',
|
||||
company: 'DAISU',
|
||||
email: 'churchlynn@daisu.com',
|
||||
phone: '+1 (896) 425-3854',
|
||||
},
|
||||
];
|
||||
144
apps/website/experimental/domain/pagination-sorting/index.html
Normal file
144
apps/website/experimental/domain/pagination-sorting/index.html
Normal file
@@ -0,0 +1,144 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Helvetica', sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>People</h1>
|
||||
<table class="js-table">
|
||||
<tr class="js-table-header">
|
||||
<th data-field="name">Name</th>
|
||||
<th data-field="age">Age</th>
|
||||
<th data-field="email">Email</th>
|
||||
</tr>
|
||||
<tbody class="js-table-body">
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="js-page-button button-prev" data-type="prev">Prev</button>
|
||||
Page <span class="js-current-page"></span> / <span class="js-total-page"></span>
|
||||
<button class="js-page-button button-next" data-type="next">Next</button>
|
||||
|
||||
<script type="text/javascript" src="data.js"></script>
|
||||
<script>
|
||||
(() => {
|
||||
function init() {
|
||||
const DOM = {
|
||||
$pageButtons: document.querySelectorAll('.js-page-button'),
|
||||
$prevButton: document.querySelector('.js-page-button.button-prev'),
|
||||
$nextButton: document.querySelector('.js-page-button.button-next'),
|
||||
$tableHeader: document.querySelector('.js-table-header'),
|
||||
$tableBody: document.querySelector('.js-table-body'),
|
||||
$currentPage: document.querySelector('.js-current-page'),
|
||||
$totalPages: document.querySelector('.js-total-page'),
|
||||
};
|
||||
|
||||
const PAGE_SIZE = 10;
|
||||
function initialState() {
|
||||
return {
|
||||
currentPage: 0,
|
||||
totalPages: 0,
|
||||
sortField: 'name',
|
||||
sortOrder: 'asc',
|
||||
data,
|
||||
};
|
||||
}
|
||||
let state = initialState();
|
||||
state.totalPages = Math.ceil(state.data.length / PAGE_SIZE);
|
||||
|
||||
function navigatePages(type) {
|
||||
let newCurrentPage = state.currentPage + (type === 'prev' ? -1 : 1);
|
||||
newCurrentPage = Math.max(0, newCurrentPage);
|
||||
newCurrentPage = Math.min(newCurrentPage, state.totalPages - 1);
|
||||
state.currentPage = newCurrentPage;
|
||||
}
|
||||
|
||||
function setSortField(field) {
|
||||
state.currentPage = 0;
|
||||
if (state.sortField !== field) {
|
||||
state.sortField = field;
|
||||
state.sortOrder = 'asc';
|
||||
} else {
|
||||
state.sortOrder = state.sortOrder === 'asc' ? 'desc' : 'asc';
|
||||
}
|
||||
}
|
||||
|
||||
function attachEventListeners() {
|
||||
// Pagination.
|
||||
DOM.$pageButtons.forEach(el => {
|
||||
el.addEventListener('click', function () {
|
||||
navigatePages(this.getAttribute('data-type'));
|
||||
render();
|
||||
});
|
||||
});
|
||||
|
||||
// Sorting.
|
||||
DOM.$tableHeader.addEventListener('click', function (event) {
|
||||
const el = event.target;
|
||||
const field = el.getAttribute('data-field');
|
||||
if (el.tagName !== 'TH' || !field) {
|
||||
return;
|
||||
}
|
||||
setSortField(field);
|
||||
render();
|
||||
});
|
||||
}
|
||||
|
||||
function render() {
|
||||
DOM.$tableBody.innerHTML = '';
|
||||
|
||||
// Sort data.
|
||||
const sortField = state.sortField;
|
||||
state.data.sort((a, b) => {
|
||||
switch (sortField) {
|
||||
case 'name':
|
||||
case 'email':
|
||||
return a[sortField] > b[sortField] ? 1 : -1;
|
||||
case 'age':
|
||||
return a[sortField] - b[sortField];
|
||||
}
|
||||
});
|
||||
if (state.sortOrder === 'desc') {
|
||||
state.data.reverse();
|
||||
}
|
||||
|
||||
// Create table rows.
|
||||
const pageData = state.data.slice(state.currentPage * PAGE_SIZE, state.currentPage * PAGE_SIZE + PAGE_SIZE);
|
||||
const $tableRowsFragment = document.createDocumentFragment();
|
||||
pageData.forEach(person => {
|
||||
const $tableRow = document.createElement('tr');
|
||||
['name', 'age', 'email'].forEach(field => {
|
||||
const $tableCell = document.createElement('td');
|
||||
$tableCell.textContent = person[field];
|
||||
$tableRow.appendChild($tableCell);
|
||||
});
|
||||
$tableRowsFragment.appendChild($tableRow);
|
||||
});
|
||||
DOM.$tableBody.appendChild($tableRowsFragment);
|
||||
|
||||
// Pagination buttons disabled states.
|
||||
DOM.$currentPage.textContent = state.currentPage + 1;
|
||||
DOM.$totalPages.textContent = state.totalPages;
|
||||
if (state.currentPage === 0) {
|
||||
DOM.$prevButton.setAttribute('disabled', true);
|
||||
} else {
|
||||
DOM.$prevButton.removeAttribute('disabled');
|
||||
}
|
||||
if (state.currentPage === state.totalPages - 1) {
|
||||
DOM.$nextButton.setAttribute('disabled', true);
|
||||
} else {
|
||||
DOM.$nextButton.removeAttribute('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
render();
|
||||
attachEventListeners();
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
66
apps/website/experimental/domain/security.md
Normal file
66
apps/website/experimental/domain/security.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# Security
|
||||
|
||||
## Encryption
|
||||
|
||||
#### Symmetric Encryption
|
||||
|
||||
- Symmetric encryption is a type of encryption where the same key is used to encrypt plaintext messages and to decrypt ciphertext.
|
||||
- Symmetric encryption is usually much less computationally expensive as compared to asymmetric encryption.
|
||||
- Often called "shared secret" encryption, or "secret key" encryption.
|
||||
- To use a symmetric encryption scheme, the sender and receiver must securely share a key in advance. This sharing can be done via asymmetric encryption or established through a key exchange algorithm like [Diffie Hellman key exchange](https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange).
|
||||
|
||||
#### Asymmetric Encryption
|
||||
|
||||
- A pair of keys are required: a **private key** and a **public key**. Public keys can be shared with anyone while private keys should be kept secret and known only to the owner.
|
||||
- A private key can be used to decrypt a message encrypted by the corresponding public key. A successful decryption verifies that the holder possesses the private key.
|
||||
- Also known as public-key cryptography.
|
||||
|
||||
## Public Key Infrastructure
|
||||
|
||||
A public key infrastructure (PKI) is a system for the creation, storage, and distribution of digital certificates which are used to verify that a particular public key belongs to a certain entity. The PKI creates digital certificates which map public keys to entities, securely stores these certificates in a central repository and revokes them if needed.
|
||||
|
||||
###### References
|
||||
|
||||
- https://www.wikiwand.com/en/Public_key_infrastructure
|
||||
|
||||
## SSH
|
||||
|
||||
An SSH session consists of two stages, **Negotiating Encryption** and **User Authentication**.
|
||||
|
||||
#### Negotiating Encryption
|
||||
|
||||
The goal of this stage is for the client and server to agree upon and establish encryption to protect future communication, by generating an identical session key. One possible algorithm to generate the session key is the Diffie–Hellman key exchange scheme. Each party generates a public/private key pair and exchanges the public key. After obtaining an authentic copy of each other's public keys, each party can compute a shared secret offline.
|
||||
|
||||
The basis of this procedure for classic Diffie-Hellman is:
|
||||
|
||||
1. Both parties agree on a large prime number, which will serve as a seed value.
|
||||
1. Both parties agree on an encryption generator (typically AES), which will be used to manipulate the values in a predefined way.
|
||||
1. Independently, each party comes up with another prime number which is kept secret from the other party. This number is used as the private key for this interaction (different than the private SSH key used for authentication).
|
||||
1. The generated private key, the encryption generator, and the shared prime number are used to generate a public key that is derived from the private key, but which can be shared with the other party.
|
||||
1. Both participants then exchange their generated public keys.
|
||||
1. The receiving entity uses their own private key, the other party's public key, and the original shared prime number to compute a shared secret key.
|
||||
1. Although this is independently computed by each party, using opposite private and public keys, it will result in the same shared secret key.
|
||||
1. The shared secret is then used to encrypt all communication that follows.
|
||||
|
||||
The purpose of the shared secret key is to wrap all further communication in an encrypted tunnel that cannot be deciphered by outsiders.
|
||||
|
||||
#### User Authentication
|
||||
|
||||
The goal of this stage is to authenticate the user and discover whether access to the server should be granted. There are two approaches for authenticating, either by using passwords, or SSH key pairs.
|
||||
|
||||
For password authentication, the server simply prompts the client for the password of the account they are attempting to login with. The password is sent through the negotiated encryption, so it is secure from outside parties.
|
||||
|
||||
Authentication using SSH key pairs begins after the symmetric encryption has been established as described in the last section. The procedure happens like this:
|
||||
|
||||
1. The client begins by sending an ID for the key pair it would like to authenticate with to the server.
|
||||
1. The server check's the `authorized_keys` file of the account that the client is attempting to log into for the key ID.
|
||||
1. If a public key with matching ID is found in the file, the server generates a random number and uses the public key to encrypt the number.
|
||||
1. The server sends the client this encrypted message.
|
||||
1. If the client actually has the associated private key, it will be able to decrypt the message using that key, revealing the original number.
|
||||
1. The client combines the decrypted number with the shared session key that is being used to encrypt the communication, and calculates the MD5 hash of this value.
|
||||
1. The client then sends this MD5 hash back to the server as an answer to the encrypted number message.
|
||||
1. The server uses the same shared session key and the original number that it sent to the client to calculate the MD5 value on its own. It compares its own calculation to the one that the client sent back. If these two values match, it proves that the client was in possession of the private key and the client is authenticated.
|
||||
|
||||
###### References
|
||||
|
||||
- https://www.digitalocean.com/community/tutorials/understanding-the-ssh-encryption-and-connection-process
|
||||
81
apps/website/experimental/domain/snake-game/snake-game.md
Normal file
81
apps/website/experimental/domain/snake-game/snake-game.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Snake Game
|
||||
|
||||
Design a snake game that is to be played in web browser.
|
||||
|
||||
Client: React + Redux
|
||||
|
||||
Rendering: Pixel-based graphics. Depending on the intended resolution, can divide the screen into N \* M pixels. Can dynamically calculate the size of each pixel.
|
||||
|
||||
Fruit: One pixel. Snake body: One pixel width made up of connected pixels.
|
||||
|
||||
Model:
|
||||
|
||||
```js
|
||||
{
|
||||
fruit: {
|
||||
x, y
|
||||
},
|
||||
snake: {
|
||||
points: [(x, y), ...] # head is at index 0
|
||||
direction: north/south/east/west
|
||||
}
|
||||
speed: 500,
|
||||
points: 0
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
function update() {
|
||||
next_loc = points[0] + (x, y) # Depends on the direction
|
||||
if (snake.points.find(next_loc) > 0) {
|
||||
// die
|
||||
}
|
||||
let pts = snake.points;
|
||||
if (!isEqual(next_loc, fruit)) {
|
||||
pts = points.removeLast();
|
||||
} else {
|
||||
generateFruit();
|
||||
points++;
|
||||
}
|
||||
snake.points = [next_loc, ...pts];
|
||||
|
||||
// Boundary checking -> die
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
function generateFruit() {
|
||||
// Cannot generate on my own body.
|
||||
|
||||
// First approach: while on body, generate
|
||||
let next_fruit_location = random_location();
|
||||
while (snake.points.find(next_fruit_location) > 0) {
|
||||
next_fruit_location = random_location();
|
||||
}
|
||||
fruit = next_fruit_location;
|
||||
|
||||
// Second approach: brute force
|
||||
for (let i = 0; i < rows; i++) {
|
||||
for (let j = 0; j < cols; j++) {
|
||||
let point = { x: i, y: j };
|
||||
if (snake.points.find(next_fruit_location) === -1) {
|
||||
fruit = point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Third approach: brute force with random
|
||||
const available_points = [];
|
||||
for (let i = 0; i < rows; i++) {
|
||||
for (let j = 0; j < cols; j++) {
|
||||
let point = { x: i, y: j };
|
||||
if (snake.points.find(next_fruit_location) === -1) {
|
||||
available_points.push(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
fruit = _.sample(available_points);
|
||||
}
|
||||
|
||||
setInterval(update, speed);
|
||||
```
|
||||
21
apps/website/experimental/domain/software-engineering.md
Normal file
21
apps/website/experimental/domain/software-engineering.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Software Engineering
|
||||
|
||||
## What is the difference between an interface and abstract class?
|
||||
|
||||
**Abstract Class**
|
||||
|
||||
- For an abstract class, a method must be declared as abstract. An abstract method doesn't have an implementation.
|
||||
- The Abstract methods can be declared with Access modifiers like public, internal, protected, etc. When implementing these methods in a subclass, you must define them with the same (or a less restricted) visibility.
|
||||
- Abstract classes can contain variables and concrete methods.
|
||||
- A class can Inherit only one Abstract class. Hence multiple inheritance is not possible for an Abstract class.
|
||||
- Abstract is object-oriented. It offers the basic data an 'object' should have and/or functions it should be able to do. It is concerned with the object's basic characteristics: what it has and what it can do. Hence objects which inherit from the same abstract class share the basic characteristics (generalization).
|
||||
- Abstract class establishes "is a" relation with concrete classes.
|
||||
|
||||
**Interface**
|
||||
|
||||
- For an interface, all the methods are abstract by default. So one cannot declare variables or concrete methods in interfaces.
|
||||
- All methods declared in an interface must be public.
|
||||
- Interfaces cannot contain variables and concrete methods except constants.
|
||||
- A class can implement many interfaces. Hence multiple interface inheritance is possible.
|
||||
- Interface is functionality-oriented. It defines functionalities an object should have. Regardless what object it is, as long as it can do these functionalities, which are defined in the interface, it's fine. It ignores everything else. An object/class can contain several (groups of) functionalities; hence it is possible for a class to implement multiple interfaces.
|
||||
- Interface provides "has a" capability for classes.
|
||||
178
apps/website/experimental/domain/tic-tac-toe/index.html
Normal file
178
apps/website/experimental/domain/tic-tac-toe/index.html
Normal file
@@ -0,0 +1,178 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Helvetica', sans-serif;
|
||||
}
|
||||
|
||||
.board-cell {
|
||||
border: 1px solid #666;
|
||||
box-sizing: border-box;
|
||||
display: inline-block;
|
||||
font-size: 32px;
|
||||
height: 100px;
|
||||
line-height: 100px;
|
||||
text-align: center;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.board-cell .content {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Tic Tac Toe</h1>
|
||||
<p>Current player turn: <span class="js-current-player"></span></p>
|
||||
<div class="js-board"></div>
|
||||
<button class="js-reset">Reset</button>
|
||||
<script>
|
||||
// We will spend the next 45 minutes building a single-page web app that implements a Tic-Tac-Toe game. jQuery has been included for you. We'll implement the following features in order:
|
||||
|
||||
// 1. Render a 3x3 board. You can hardcode some X and O values within the cell for starters.
|
||||
// 2. Implement the add symbol functionality that adds a X or O into a cell whenever the player clicks on it.
|
||||
// 3. Rotate between the players whenever a move is made. Update the current player display.
|
||||
// 4. Check for end game conditions after each move and display the winner if any.
|
||||
// horizontally, vertically, diagonally
|
||||
// 5. After a winner has been determined, disable further moves on the board.
|
||||
// 6. Add a button to reset the game state.
|
||||
(() => {
|
||||
function init() {
|
||||
const DOM = {
|
||||
$currentPlayer: document.querySelector('.js-current-player'),
|
||||
$board: document.querySelector('.js-board'),
|
||||
$resetButton: document.querySelector('.js-reset'),
|
||||
};
|
||||
const SIZE = 3;
|
||||
function initialState() {
|
||||
return {
|
||||
boardModel: Array(SIZE).fill(null).map(_ => Array(SIZE).fill(null)),
|
||||
players: ['X', 'O'],
|
||||
currentPlayer: 0,
|
||||
gameEnded: false,
|
||||
turn: 0,
|
||||
};
|
||||
}
|
||||
let state = initialState();
|
||||
|
||||
function renderBoard() {
|
||||
DOM.$currentPlayer.textContent = state.players[state.currentPlayer];
|
||||
// Assuming SIZE > 0.
|
||||
DOM.$board.innerHTML = '';
|
||||
for (let i = 0; i < SIZE; i++) {
|
||||
const $row = document.createElement('div');
|
||||
$row.classList.add('board-row');
|
||||
for (let j = 0; j < SIZE; j++) {
|
||||
const $cell = document.createElement('div');
|
||||
$cell.classList.add('board-cell');
|
||||
$cell.setAttribute('data-i', i);
|
||||
$cell.setAttribute('data-j', j);
|
||||
const $content = document.createElement('span');
|
||||
$content.classList.add('content');
|
||||
$content.textContent = state.boardModel[i][j];
|
||||
$cell.appendChild($content);
|
||||
$row.appendChild($cell);
|
||||
}
|
||||
DOM.$board.appendChild($row);
|
||||
}
|
||||
}
|
||||
|
||||
function checkWinning(board, player) {
|
||||
// Check horizontal.
|
||||
for (let i = 0; i < SIZE; i++) {
|
||||
if (board[i].every(cell => cell === player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check vertical.
|
||||
for (let j = 0; j < SIZE; j++) {
|
||||
let verticalAllPlayer = true;
|
||||
for (let i = 0; i < SIZE; i++) {
|
||||
if (board[i][j] !== player) {
|
||||
verticalAllPlayer = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (verticalAllPlayer) {
|
||||
return verticalAllPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
// Check diagonal South-East.
|
||||
let diagonalAllPlayer = true;
|
||||
for (let i = 0; i < SIZE; i++) {
|
||||
if (board[i][i] !== player) {
|
||||
diagonalAllPlayer = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (diagonalAllPlayer) {
|
||||
return diagonalAllPlayer;
|
||||
}
|
||||
|
||||
// Check diagonal North-East.
|
||||
diagonalAllPlayer = true;
|
||||
for (let i = SIZE - 1, j = 0; i >= 0; i--, j++) {
|
||||
if (board[i][j] !== player) {
|
||||
diagonalAllPlayer = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (diagonalAllPlayer) {
|
||||
return diagonalAllPlayer;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function attachEventListeners() {
|
||||
DOM.$board.addEventListener('click', (event) => {
|
||||
if (state.gameEnded) {
|
||||
return;
|
||||
}
|
||||
if (!event.target.classList.contains('board-cell')) {
|
||||
return;
|
||||
}
|
||||
const $cell = event.target;
|
||||
const i = parseInt($cell.getAttribute('data-i'), 10);
|
||||
const j = parseInt($cell.getAttribute('data-j'), 10);
|
||||
if (state.boardModel[i][j] !== null) {
|
||||
alert('Cell has already been taken!');
|
||||
return;
|
||||
}
|
||||
const player = state.players[state.currentPlayer];
|
||||
state.boardModel[i][j] = player;
|
||||
const winningMove = checkWinning(state.boardModel, player);
|
||||
state.turn++;
|
||||
if (!winningMove) {
|
||||
state.currentPlayer = (state.currentPlayer + 1) % 2;
|
||||
renderBoard();
|
||||
if (state.turn === SIZE * SIZE) {
|
||||
alert('It\'s a draw!');
|
||||
}
|
||||
} else {
|
||||
renderBoard();
|
||||
state.gameEnded = true;
|
||||
alert(`Player ${player} wins!`);
|
||||
}
|
||||
});
|
||||
|
||||
DOM.$resetButton.addEventListener('click', () => {
|
||||
if (confirm('Start a new game?')) {
|
||||
state = initialState();
|
||||
renderBoard();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
renderBoard();
|
||||
attachEventListeners();
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
3
apps/website/experimental/front-end/README.md
Normal file
3
apps/website/experimental/front-end/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Front-end Job Interview Questions
|
||||
|
||||
Front-end Job Interview Questions have been migrated [here](https://github.com/yangshun/front-end-interview-handbook).
|
||||
18
apps/website/experimental/interviewers/basics.md
Normal file
18
apps/website/experimental/interviewers/basics.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Basics
|
||||
|
||||
## Disclaimer
|
||||
|
||||
All these items will change based on your specific company and needs but these items area are the starting point.
|
||||
|
||||
## Items To Consider
|
||||
|
||||
- **Timeliness** - The interviewee should show up on time, but of course things happen and we must all be understanding that things outside of their control may happen. Try to give a few minutes leeway.
|
||||
- **Strengths** - Ask the interviewee what they would consider to be their strengths and maybe rate themselves. This gives you a good idea where to start asking technical questions and sets a baseline for expected knowledge of each subject.
|
||||
- **Keep Things Loose** - This is of course dependent on your industry but try to keep make the interviewee comfortable. Many people get nervous when trying to perform at their best for others and a technical interview is no different. A suggestion is to start with a personal question such as "What are some of your hobbies?" or "What do you like to do for fun?" These types of questions can help relax an interviewee and allows them to perform better.
|
||||
- **Understand The Position** - Understand that a junior level candidate isn't going to have as much knowledge about languages and frameworks as a senior candidate will.
|
||||
- **Save Time For Questions** - The interviewee may have questions for you! Give them the ability to ask. Maybe offer up a few questions if they have none, (ie. "What is the typical day here like for my position?", "What is your favorite part about working at \_\_?")
|
||||
|
||||
## Tech Question Technique
|
||||
|
||||
- **Tools** - Using a text editor such as Sublime or Atom will give the interviewee syntax highlighting but doesn't show compiler errors which can be a help.
|
||||
- **Nitpicking** - Sometimes pseudocode is okay. If testing in C# do you really need the interviewee to write `Console.WriteLine()` or is `Print()` good enough? -**Keep Dialog Open** - Don't leave the interviewee alone or sit quietly by as they attempt to code. Give some subtle hints like "I see you're doing \_\_\_\_, can you think of any other ways to accomplish this?" It's unlikely that the interviewee will be working in a silo should they get the job, is there any reason they should be during the interview?
|
||||
91
apps/website/experimental/topics.md
Normal file
91
apps/website/experimental/topics.md
Normal file
@@ -0,0 +1,91 @@
|
||||
---
|
||||
id: topics
|
||||
title: Topics
|
||||
---
|
||||
|
||||
## Arrays
|
||||
|
||||
## Strings
|
||||
|
||||
- Prefix trees (Tries)
|
||||
- Suffix trees
|
||||
- Suffix arrays
|
||||
- KMP
|
||||
- Rabin-Karp
|
||||
- Boyer-Moore
|
||||
|
||||
## Sorting
|
||||
|
||||
- Bubble sort
|
||||
- Insertion sort
|
||||
- Merge sort
|
||||
- Quick sort
|
||||
- Selection sort
|
||||
- Bucket sort
|
||||
- Radix sort
|
||||
- Counting sort
|
||||
|
||||
## Linked Lists
|
||||
|
||||
## Stacks
|
||||
|
||||
## Queues
|
||||
|
||||
## Hash tables
|
||||
|
||||
- Collision resolution algorithms
|
||||
|
||||
## Trees
|
||||
|
||||
- BFS
|
||||
- DFS (inorder, postorder, preorder)
|
||||
- Height
|
||||
|
||||
## Binary Search Trees
|
||||
|
||||
- Insert node
|
||||
- Delete a node
|
||||
- Find element in BST
|
||||
- Find min, max element in BST
|
||||
- Get successor element in tree
|
||||
- Check if a binary tree is a BST or not
|
||||
|
||||
## Heaps / Priority Queues
|
||||
|
||||
- Insert
|
||||
- Bubble up
|
||||
- Extract max
|
||||
- Remove
|
||||
- Heapify
|
||||
- Heap sort
|
||||
|
||||
## Graphs
|
||||
|
||||
- Various implementations
|
||||
- Adjacency matrix
|
||||
- Adjacency list
|
||||
- Adjacency map
|
||||
- Single-source shortest path
|
||||
- Dijkstra
|
||||
- Bellman-Ford
|
||||
- Topo sort
|
||||
- MST
|
||||
- Prim algorithm
|
||||
- Kruskal's algorithm
|
||||
- Union Find Data Structure
|
||||
- Count connected components in a graph
|
||||
- List strongly connected components in a graph
|
||||
- Check for bipartite graph
|
||||
|
||||
## Dynamic Programming
|
||||
|
||||
- Count Change
|
||||
- 0-1 Knapsack
|
||||
|
||||
## System Design
|
||||
|
||||
- http://www.hiredintech.com/system-design/
|
||||
- https://www.quora.com/How-do-I-prepare-to-answer-design-questions-in-a-technical-interview?redirected_qid=1500023
|
||||
- http://blog.gainlo.co/index.php/2015/10/22/8-things-you-need-to-know-before-system-design-interviews/
|
||||
- https://github.com/donnemartin/system-design-primer
|
||||
- https://github.com/jwasham/coding-interview-university/blob/master/extras/cheat%20sheets/system-design.pdf
|
||||
18
apps/website/experimental/utilities/javascript/binToInt.js
Normal file
18
apps/website/experimental/utilities/javascript/binToInt.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// Does not handle negative binary numbers.
|
||||
function binToInt(binary) {
|
||||
let res = 0;
|
||||
for (let i = 0; i < binary.length; i++) {
|
||||
res = res * 2 + +binary[i];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
console.log(binToInt('0') === parseInt('0', 2) && parseInt('0', 2) === 0);
|
||||
console.log(binToInt('1') === parseInt('1', 2) && parseInt('1', 2) === 1);
|
||||
console.log(binToInt('10') === parseInt('10', 2) && parseInt('10', 2) === 2);
|
||||
console.log(binToInt('11') === parseInt('11', 2) && parseInt('11', 2) === 3);
|
||||
console.log(binToInt('101') === parseInt('101', 2) && parseInt('101', 2) === 5);
|
||||
console.log(
|
||||
binToInt('1100011') === parseInt('1100011', 2) &&
|
||||
parseInt('1100011', 2) === 99,
|
||||
);
|
||||
@@ -0,0 +1,26 @@
|
||||
function binarySearch(arr, target) {
|
||||
let left = 0;
|
||||
let right = arr.length - 1;
|
||||
while (left <= right) {
|
||||
const mid = left + Math.floor((right - left) / 2);
|
||||
if (arr[mid] === target) {
|
||||
return mid;
|
||||
}
|
||||
if (arr[mid] < target) {
|
||||
left = mid + 1;
|
||||
} else {
|
||||
right = mid - 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
console.log(binarySearch([1, 2, 3, 10], 1) === 0);
|
||||
console.log(binarySearch([1, 2, 3, 10], 2) === 1);
|
||||
console.log(binarySearch([1, 2, 3, 10], 3) === 2);
|
||||
console.log(binarySearch([1, 2, 3, 10], 10) === 3);
|
||||
console.log(binarySearch([1, 2, 3, 10], 9) === -1);
|
||||
console.log(binarySearch([1, 2, 3, 10], 4) === -1);
|
||||
console.log(binarySearch([1, 2, 3, 10], 0) === -1);
|
||||
console.log(binarySearch([1, 2, 3, 10], 11) === -1);
|
||||
console.log(binarySearch([5, 7, 8, 10], 3) === -1);
|
||||
43
apps/website/experimental/utilities/javascript/deepEqual.js
Normal file
43
apps/website/experimental/utilities/javascript/deepEqual.js
Normal file
@@ -0,0 +1,43 @@
|
||||
function deepEqual(val1, val2) {
|
||||
if (typeof val1 !== typeof val2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Array comparison.
|
||||
if (Array.isArray(val1) && Array.isArray(val2)) {
|
||||
if (val1.length !== val2.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < val1.length; i++) {
|
||||
if (!deepEqual(val1[i], val2[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Object comparison.
|
||||
if (
|
||||
typeof val1 === 'object' &&
|
||||
typeof val2 === 'object' &&
|
||||
val1 !== null &&
|
||||
val2 !== null
|
||||
) {
|
||||
const keys1 = Object.keys(val1),
|
||||
keys2 = Object.keys(val2);
|
||||
if (keys1.length !== keys2.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < keys1.length; i++) {
|
||||
if (!deepEqual(val1[keys1[i]], val2[keys2[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Primitive comparison.
|
||||
return val1 === val2;
|
||||
}
|
||||
|
||||
module.exports = deepEqual;
|
||||
@@ -0,0 +1,40 @@
|
||||
function graphTopoSort(numberNodes, edges) {
|
||||
const nodes = new Map();
|
||||
const order = [];
|
||||
const queue = [];
|
||||
for (let i = 0; i < numberNodes; i++) {
|
||||
nodes.set(i, { in: 0, out: new Set() });
|
||||
}
|
||||
|
||||
edges.forEach((edge) => {
|
||||
const [node_id, pre_id] = edge;
|
||||
nodes.get(node_id).in += 1;
|
||||
nodes.get(pre_id).out.add(node_id);
|
||||
});
|
||||
|
||||
for (let [node_id, value] of nodes.entries()) {
|
||||
if (value.in === 0) {
|
||||
queue.push(node_id);
|
||||
}
|
||||
}
|
||||
|
||||
while (queue.length) {
|
||||
const node_id = queue.shift();
|
||||
for (let outgoing_id of nodes.get(node_id).out) {
|
||||
nodes.get(outgoing_id).in -= 1;
|
||||
if (nodes.get(outgoing_id).in === 0) {
|
||||
queue.push(outgoing_id);
|
||||
}
|
||||
}
|
||||
order.push(node_id);
|
||||
}
|
||||
|
||||
return order.length == numberNodes ? order : [];
|
||||
}
|
||||
|
||||
console.log(
|
||||
graphTopoSort(3, [
|
||||
[0, 1],
|
||||
[0, 2],
|
||||
]),
|
||||
);
|
||||
21
apps/website/experimental/utilities/javascript/intToBin.js
Normal file
21
apps/website/experimental/utilities/javascript/intToBin.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// Does not handle negative numbers.
|
||||
function intToBin(number) {
|
||||
if (number === 0) {
|
||||
return '0';
|
||||
}
|
||||
let res = '';
|
||||
while (number > 0) {
|
||||
res = String(number % 2) + res;
|
||||
number = parseInt(number / 2, 10);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
console.log(intToBin(0) === (0).toString(2) && (0).toString(2) === '0');
|
||||
console.log(intToBin(1) === (1).toString(2) && (1).toString(2) === '1');
|
||||
console.log(intToBin(2) === (2).toString(2) && (2).toString(2) === '10');
|
||||
console.log(intToBin(3) === (3).toString(2) && (3).toString(2) === '11');
|
||||
console.log(intToBin(5) === (5).toString(2) && (5).toString(2) === '101');
|
||||
console.log(
|
||||
intToBin(99) === (99).toString(2) && (99).toString(2) === '1100011',
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
// Interval: [start, end].
|
||||
function intervalsIntersect(a, b) {
|
||||
return a[0] < b[1] && b[0] < a[1];
|
||||
}
|
||||
|
||||
console.log(intervalsIntersect([1, 2], [3, 4]) === false);
|
||||
console.log(intervalsIntersect([1, 2], [2, 4]) === false);
|
||||
console.log(intervalsIntersect([1, 2], [1, 4]) === true);
|
||||
console.log(intervalsIntersect([1, 2], [0, 4]) === true);
|
||||
console.log(intervalsIntersect([1, 2], [0, 2]) === true);
|
||||
console.log(intervalsIntersect([1, 2], [0, 1.5]) === true);
|
||||
console.log(intervalsIntersect([3, 4], [1, 2]) === false);
|
||||
console.log(intervalsIntersect([2, 4], [1, 2]) === false);
|
||||
console.log(intervalsIntersect([1, 4], [1, 2]) === true);
|
||||
console.log(intervalsIntersect([0, 4], [1, 2]) === true);
|
||||
console.log(intervalsIntersect([0, 2], [1, 2]) === true);
|
||||
console.log(intervalsIntersect([0, 1.5], [1, 2]) === true);
|
||||
@@ -0,0 +1,16 @@
|
||||
// Interval: [start, end].
|
||||
// Merges two overlapping intervals into one.
|
||||
function intervalsMerge(a, b) {
|
||||
return [Math.min(a[0], b[0]), Math.max(a[1], b[1])];
|
||||
}
|
||||
|
||||
const deepEqual = require('./deepEqual');
|
||||
|
||||
console.log(deepEqual(intervalsMerge([1, 2], [1, 4]), [1, 4]));
|
||||
console.log(deepEqual(intervalsMerge([1, 2], [0, 4]), [0, 4]));
|
||||
console.log(deepEqual(intervalsMerge([1, 2], [0, 2]), [0, 2]));
|
||||
console.log(deepEqual(intervalsMerge([1, 2], [0, 1.5]), [0, 2]));
|
||||
console.log(deepEqual(intervalsMerge([1, 4], [1, 2]), [1, 4]));
|
||||
console.log(deepEqual(intervalsMerge([0, 4], [1, 2]), [0, 4]));
|
||||
console.log(deepEqual(intervalsMerge([0, 2], [1, 2]), [0, 2]));
|
||||
console.log(deepEqual(intervalsMerge([0, 1.5], [1, 2]), [0, 2]));
|
||||
@@ -0,0 +1,19 @@
|
||||
function isSubsequence(s, t) {
|
||||
if (s.length > t.length) {
|
||||
return false;
|
||||
}
|
||||
let matchedLength = 0;
|
||||
for (let i = 0; i < t.length; i++) {
|
||||
if (matchedLength < s.length && s[matchedLength] === t[i]) {
|
||||
matchedLength += 1;
|
||||
}
|
||||
}
|
||||
return matchedLength === s.length;
|
||||
}
|
||||
|
||||
console.log(isSubsequence('abc', 'abcde') === true);
|
||||
console.log(isSubsequence('abd', 'abcde') === true);
|
||||
console.log(isSubsequence('abf', 'abcde') === false);
|
||||
console.log(isSubsequence('abef', 'abcde') === false);
|
||||
console.log(isSubsequence('abcdef', 'abcde') === false);
|
||||
console.log(isSubsequence('a', 'abcde') === true);
|
||||
@@ -0,0 +1,61 @@
|
||||
function matrixClone(matrix, defaultValue) {
|
||||
return matrix.map((row) => {
|
||||
return defaultValue === undefined
|
||||
? row.slice(0)
|
||||
: Array(row.length).fill(defaultValue);
|
||||
});
|
||||
}
|
||||
|
||||
const deepEqual = require('./deepEqual');
|
||||
|
||||
// Test clone.
|
||||
const a = [
|
||||
[1, 2],
|
||||
[1, 4],
|
||||
];
|
||||
console.log(
|
||||
deepEqual(matrixClone(a), [
|
||||
[1, 2],
|
||||
[1, 4],
|
||||
]),
|
||||
);
|
||||
a[0][0] = 4;
|
||||
console.log(
|
||||
deepEqual(matrixClone(a), [
|
||||
[1, 2],
|
||||
[1, 4],
|
||||
]) === false,
|
||||
);
|
||||
console.log(deepEqual(matrixClone([[1]]), [[1]]));
|
||||
|
||||
// Test clone with default value.
|
||||
console.log(
|
||||
deepEqual(
|
||||
matrixClone(
|
||||
[
|
||||
[1, 2],
|
||||
[1, 4],
|
||||
],
|
||||
1,
|
||||
),
|
||||
[
|
||||
[1, 1],
|
||||
[1, 1],
|
||||
],
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
deepEqual(
|
||||
matrixClone(
|
||||
[
|
||||
[1, 2],
|
||||
[1, 4],
|
||||
],
|
||||
null,
|
||||
),
|
||||
[
|
||||
[null, null],
|
||||
[null, null],
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,33 @@
|
||||
function matrixTranspose(matrix) {
|
||||
return matrix[0].map((col, i) => matrix.map((row) => row[i]));
|
||||
}
|
||||
|
||||
const deepEqual = require('./deepEqual');
|
||||
|
||||
console.log(deepEqual(matrixTranspose([[1]]), [[1]]));
|
||||
console.log(deepEqual(matrixTranspose([[1, 2]]), [[1], [2]]));
|
||||
console.log(
|
||||
deepEqual(
|
||||
matrixTranspose([
|
||||
[1, 2],
|
||||
[1, 4],
|
||||
]),
|
||||
[
|
||||
[1, 1],
|
||||
[2, 4],
|
||||
],
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
deepEqual(
|
||||
matrixTranspose([
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
]),
|
||||
[
|
||||
[1, 4],
|
||||
[2, 5],
|
||||
[3, 6],
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,35 @@
|
||||
function traverse(matrix) {
|
||||
const DIRECTIONS = [
|
||||
[0, 1],
|
||||
[0, -1],
|
||||
[1, 0],
|
||||
[-1, 0],
|
||||
];
|
||||
const rows = matrix.length;
|
||||
const cols = matrix[0].length;
|
||||
const visited = matrix.map((row) => Array(row.length).fill(false));
|
||||
function dfs(i, j) {
|
||||
if (visited[i][j]) {
|
||||
return;
|
||||
}
|
||||
visited[i][j] = true;
|
||||
DIRECTIONS.forEach((dir) => {
|
||||
const row = i + dir[0],
|
||||
col = j + dir[1];
|
||||
// Boundary check.
|
||||
if (row < 0 || row >= rows || col < 0 || col >= cols) {
|
||||
return;
|
||||
}
|
||||
// Valid neighbor check.
|
||||
if (matrix[row][col] !== 1) {
|
||||
return;
|
||||
}
|
||||
dfs(row, col);
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < rows; i++) {
|
||||
for (let j = 0; j < cols; j++) {
|
||||
dfs(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
50
apps/website/experimental/utilities/javascript/mergeSort.js
Normal file
50
apps/website/experimental/utilities/javascript/mergeSort.js
Normal file
@@ -0,0 +1,50 @@
|
||||
function mergeSort(arr) {
|
||||
if (arr.length < 2) {
|
||||
// Arrays of length 0 or 1 are sorted by definition.
|
||||
return arr;
|
||||
}
|
||||
|
||||
const left = arr.slice(0, Math.floor(arr.length / 2));
|
||||
const right = arr.slice(Math.floor(arr.length / 2), Math.floor(arr.length));
|
||||
|
||||
return merge(mergeSort(left), mergeSort(right));
|
||||
}
|
||||
|
||||
function merge(arr1, arr2) {
|
||||
const merged = [];
|
||||
let i = 0,
|
||||
j = 0;
|
||||
|
||||
while (i < arr1.length && j < arr2.length) {
|
||||
if (arr1[i] <= arr2[j]) {
|
||||
merged.push(arr1[i]);
|
||||
i++;
|
||||
} else if (arr2[j] < arr1[i]) {
|
||||
merged.push(arr2[j]);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
merged.push(...arr1.slice(i), ...arr2.slice(j));
|
||||
return merged;
|
||||
}
|
||||
|
||||
const deepEqual = require('./deepEqual');
|
||||
|
||||
console.log(deepEqual(mergeSort([]), []));
|
||||
console.log(deepEqual(mergeSort([1]), [1]));
|
||||
console.log(deepEqual(mergeSort([2, 1]), [1, 2]));
|
||||
console.log(deepEqual(mergeSort([7, 2, 4, 3, 1, 2]), [1, 2, 2, 3, 4, 7]));
|
||||
console.log(deepEqual(mergeSort([1, 2, 3, 4, 5, 0]), [0, 1, 2, 3, 4, 5]));
|
||||
console.log(
|
||||
deepEqual(
|
||||
mergeSort([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
deepEqual(
|
||||
mergeSort([98322, 3242, 876, -234, 34, 12331]),
|
||||
[-234, 34, 876, 3242, 12331, 98322],
|
||||
),
|
||||
);
|
||||
13
apps/website/experimental/utilities/javascript/treeEqual.js
Normal file
13
apps/website/experimental/utilities/javascript/treeEqual.js
Normal file
@@ -0,0 +1,13 @@
|
||||
function treeEqual(node1, node2) {
|
||||
if (!node1 && !node2) {
|
||||
return true;
|
||||
}
|
||||
if (!node1 || !node2) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
node1.val == node2.val &&
|
||||
treeEqual(node1.left, node2.left) &&
|
||||
treeEqual(node1.right, node2.right)
|
||||
);
|
||||
}
|
||||
10
apps/website/experimental/utilities/javascript/treeMirror.js
Normal file
10
apps/website/experimental/utilities/javascript/treeMirror.js
Normal file
@@ -0,0 +1,10 @@
|
||||
function treeMirror(node) {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
let temp = node.left;
|
||||
node.left = node.right;
|
||||
node.right = temp;
|
||||
treeMirror(node.left);
|
||||
treeMirror(node.right);
|
||||
}
|
||||
68
apps/website/experimental/utilities/python/binary_search.py
Normal file
68
apps/website/experimental/utilities/python/binary_search.py
Normal file
@@ -0,0 +1,68 @@
|
||||
def binary_search(arr, target):
|
||||
left = 0;
|
||||
right = len(arr) - 1
|
||||
while left <= right:
|
||||
mid = left + (right - left) // 2;
|
||||
if arr[mid] == target:
|
||||
return mid
|
||||
elif arr[mid] < target:
|
||||
left = mid + 1
|
||||
else:
|
||||
right = mid - 1
|
||||
return -1
|
||||
|
||||
def bisect_left(arr, target):
|
||||
"""Returns the leftmost position that `target` should
|
||||
go to such that the sequence remains sorted."""
|
||||
left = 0
|
||||
right = len(arr)
|
||||
while left < right:
|
||||
mid = (left + right) // 2
|
||||
if arr[mid] < target:
|
||||
left = mid + 1
|
||||
else:
|
||||
right = mid
|
||||
return left
|
||||
|
||||
def bisect_right(arr, target):
|
||||
"""Returns the rightmost position that `target` should
|
||||
go to such that the sequence remains sorted."""
|
||||
left = 0
|
||||
right = len(arr)
|
||||
while left < right:
|
||||
mid = (left + right) // 2
|
||||
if arr[mid] > target:
|
||||
right = mid
|
||||
else:
|
||||
left = mid + 1
|
||||
return left
|
||||
|
||||
print(binary_search([1, 2, 3, 10], 1) == 0)
|
||||
print(binary_search([1, 2, 3, 10], 2) == 1)
|
||||
print(binary_search([1, 2, 3, 10], 3) == 2)
|
||||
print(binary_search([1, 2, 3, 10], 10) == 3)
|
||||
print(binary_search([1, 2, 3, 10], 9) == -1)
|
||||
print(binary_search([1, 2, 3, 10], 4) == -1)
|
||||
print(binary_search([1, 2, 3, 10], 0) == -1)
|
||||
print(binary_search([1, 2, 3, 10], 11) == -1)
|
||||
print(binary_search([5, 7, 8, 10], 3) == -1)
|
||||
|
||||
print(bisect_left([1, 2, 3, 3, 10], 1) == 0)
|
||||
print(bisect_left([1, 2, 3, 3, 10], 2) == 1)
|
||||
print(bisect_left([1, 2, 3, 3, 10], 3) == 2) # First "3" is at index 2
|
||||
print(bisect_left([1, 2, 3, 3, 10], 10) == 4)
|
||||
|
||||
# These return a valid index despite target not being in array.
|
||||
print(bisect_left([1, 2, 3, 3, 10], 9) == 4)
|
||||
print(bisect_left([1, 2, 3, 3, 10], 0) == 0) # Insert "0" at front
|
||||
print(bisect_left([1, 2, 3, 3, 10], 11) == 5) # Insert "5" at back
|
||||
|
||||
print(bisect_right([1, 2, 3, 3, 10], 1) == 1)
|
||||
print(bisect_right([1, 2, 3, 3, 10], 2) == 2)
|
||||
print(bisect_right([1, 2, 3, 3, 10], 3) == 4) # Last "3" is at index 3, so insert new "3" at index 4
|
||||
print(bisect_right([1, 2, 3, 3, 10], 10) == 5)
|
||||
|
||||
# These return a valid index despite target not being in array.
|
||||
print(bisect_right([1, 2, 3, 3, 10], 9) == 4)
|
||||
print(bisect_right([1, 2, 3, 3, 10], 0) == 0) # Insert "0" at front
|
||||
print(bisect_right([1, 2, 3, 3, 10], 11) == 5) # Insert "5" at back
|
||||
19
apps/website/experimental/utilities/python/char_prime_map.py
Normal file
19
apps/website/experimental/utilities/python/char_prime_map.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# For mapping a lowercase character to a prime number.
|
||||
# Useful for checking whether two strings are anagram or permutations of each other.
|
||||
primes = {
|
||||
'a': 2, 'b': 3, 'c': 5, 'd': 7, 'e': 11, 'f': 13,
|
||||
'g': 17, 'h': 19, 'i': 23, 'j': 29, 'k': 31, 'l': 37,
|
||||
'm': 41, 'n': 43, 'o': 47, 'p': 53, 'q': 59, 'r': 61,
|
||||
's': 67, 't': 71, 'u': 73, 'v': 79, 'w': 83, 'x': 89,
|
||||
'y': 97, 'z': 101, ' ': 103,
|
||||
}
|
||||
|
||||
import functools
|
||||
|
||||
def mul(seq):
|
||||
return functools.reduce(lambda a, b: a * b, seq, 1)
|
||||
|
||||
def prime_value_of_string(string):
|
||||
return mul([primes[c] for c in string])
|
||||
|
||||
print(prime_value_of_string('abcde'))
|
||||
45
apps/website/experimental/utilities/python/graph_dfs.py
Normal file
45
apps/website/experimental/utilities/python/graph_dfs.py
Normal file
@@ -0,0 +1,45 @@
|
||||
def graph_dfs(matrix):
|
||||
rows, cols = len(matrix), len(matrix[0])
|
||||
visited = set()
|
||||
directions = ((0, 1), (0, -1), (1, 0), (-1, 0))
|
||||
def dfs(i, j):
|
||||
if (i, j) in visited:
|
||||
return
|
||||
visited.add((i, j))
|
||||
# Traverse neighbors.
|
||||
for direction in directions:
|
||||
next_i, next_j = i + direction[0], j + direction[1]
|
||||
if 0 <= next_i < rows and 0 <= next_j < cols: # Check boundary.
|
||||
# Add any other checking here ^
|
||||
dfs(next_i, next_j)
|
||||
|
||||
for i in range(rows):
|
||||
for j in range(cols):
|
||||
dfs(i, j)
|
||||
|
||||
# Follow up:
|
||||
# 1) Diagonal cells are considered neighbors
|
||||
# 2) View the matrix like Earth, right boundary is adjacent to the left boundary, top adjacent to left, etc.
|
||||
def graph_dfs_diagonals_and_boundary_wrap(matrix):
|
||||
rows, cols = len(matrix), len(matrix[0])
|
||||
visited = set()
|
||||
# Change 1: Add 4 more diagonal directions.
|
||||
directions = ((0, 1), (0, -1), (1, 0), (-1, 0), (-1, -1), (1, 1), (1, -1), (-1, 1))
|
||||
def dfs(i, j):
|
||||
if (i, j) in visited:
|
||||
return
|
||||
visited.add((i, j))
|
||||
for direction in directions:
|
||||
# Change 2: No more boundary, use modulo to allow traversal that exceed boundaries to wrap around.
|
||||
next_i, next_j = (i + direction[0] + rows) % rows, (j + direction[1] + cols) % cols
|
||||
dfs(next_i, next_j)
|
||||
|
||||
for i in range(rows):
|
||||
for j in range(cols):
|
||||
dfs(i, j)
|
||||
|
||||
graph_dfs([
|
||||
[1, 2, 3, 4],
|
||||
[5, 6, 7, 8],
|
||||
[9, 10, 11, 12],
|
||||
])
|
||||
@@ -0,0 +1,22 @@
|
||||
def graph_topo_sort(num_nodes, edges):
|
||||
from collections import deque
|
||||
nodes, order, queue = {}, [], deque()
|
||||
for node_id in range(num_nodes):
|
||||
nodes[node_id] = { 'in': 0, 'out': set() }
|
||||
for node_id, pre_id in edges:
|
||||
nodes[node_id]['in'] += 1
|
||||
nodes[pre_id]['out'].add(node_id)
|
||||
for node_id in nodes.keys():
|
||||
if nodes[node_id]['in'] == 0:
|
||||
queue.append(node_id)
|
||||
while len(queue):
|
||||
node_id = queue.pop()
|
||||
for outgoing_id in nodes[node_id]['out']:
|
||||
nodes[outgoing_id]['in'] -= 1
|
||||
if nodes[outgoing_id]['in'] == 0:
|
||||
queue.append(outgoing_id)
|
||||
order.append(node_id)
|
||||
return order if len(order) == num_nodes else None
|
||||
|
||||
print(graph_topo_sort(4, [[0, 1], [0, 2], [2, 1], [3, 0]]))
|
||||
# [1, 2, 0,3 ]
|
||||
84
apps/website/experimental/utilities/python/heap.py
Normal file
84
apps/website/experimental/utilities/python/heap.py
Normal file
@@ -0,0 +1,84 @@
|
||||
# Implements a min-heap. For max-heap, simply reverse all comparison orders.
|
||||
#
|
||||
# Note on alternate subroutine namings (used in some textbooks):
|
||||
# - _bubble_up = siftdown
|
||||
# - _bubble_down = siftup
|
||||
|
||||
def _bubble_up(heap, i):
|
||||
while i > 0:
|
||||
parent_i = (i - 1) // 2
|
||||
if heap[i] < heap[parent_i]:
|
||||
heap[i], heap[parent_i] = heap[parent_i], heap[i]
|
||||
i = parent_i
|
||||
continue
|
||||
break
|
||||
|
||||
def _bubble_down(heap, i):
|
||||
startpos = i
|
||||
newitem = heap[i]
|
||||
left_i = 2 * i + 1
|
||||
while left_i < len(heap):
|
||||
# Pick the smaller of the L and R children
|
||||
right_i = left_i + 1
|
||||
if right_i < len(heap) and not heap[left_i] < heap[right_i]:
|
||||
child_i = right_i
|
||||
else:
|
||||
child_i = left_i
|
||||
|
||||
# Break if heap invariant satisfied
|
||||
if heap[i] < heap[child_i]:
|
||||
break
|
||||
|
||||
# Move the smaller child up.
|
||||
heap[i], heap[child_i] = heap[child_i], heap[i]
|
||||
i = child_i
|
||||
left_i = 2 * i + 1
|
||||
|
||||
def heapify(lst):
|
||||
for i in reversed(range(len(lst) // 2)):
|
||||
_bubble_down(lst, i)
|
||||
|
||||
def heappush(heap, item):
|
||||
heap.append(item)
|
||||
_bubble_up(heap, len(heap) - 1)
|
||||
|
||||
def heappop(heap):
|
||||
if len(heap) == 1:
|
||||
return heap.pop()
|
||||
min_value = heap[0]
|
||||
heap[0] = heap[-1]
|
||||
del heap[-1]
|
||||
_bubble_down(heap, 0)
|
||||
return min_value
|
||||
|
||||
|
||||
|
||||
# Example usage
|
||||
heap = [3, 2, 1, 0]
|
||||
heapify(heap)
|
||||
print('Heap(0, 1, 2, 3):', heap)
|
||||
heappush(heap, 4)
|
||||
heappush(heap, 7)
|
||||
heappush(heap, 6)
|
||||
heappush(heap, 5)
|
||||
print('Heap(0, 1, 2, 3, 4, 5, 6, 7):', heap)
|
||||
|
||||
sorted_list = [heappop(heap) for _ in range(8)]
|
||||
print('Heap-sorted list:', sorted_list)
|
||||
|
||||
# Large test case, for randomized tests
|
||||
import random
|
||||
|
||||
# Heapify 0 ~ 99
|
||||
heap = list(range(100))
|
||||
random.shuffle(heap)
|
||||
heapify(heap)
|
||||
|
||||
# Push 100 ~ 199 in random order
|
||||
new_elems = list(range(100, 200))
|
||||
random.shuffle(new_elems)
|
||||
for elem in new_elems:
|
||||
heappush(heap, elem)
|
||||
|
||||
sorted_list = [heappop(heap) for _ in range(200)]
|
||||
print(sorted_list == sorted(sorted_list))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user