Code Monkey home page Code Monkey logo

yangshun / tech-interview-handbook Goto Github PK

View Code? Open in Web Editor NEW
110.0K 2.1K 13.8K 30.75 MB

💯 Curated coding interview preparation materials for busy software engineers

Home Page: https://www.techinterviewhandbook.org

License: MIT License

HTML 1.00% JavaScript 7.83% Python 1.68% CSS 0.64% TypeScript 88.85%
interview-questions coding-interviews interview-practice interview-preparation algorithm algorithms system-design behavioral-interviews algorithm-interview algorithm-interview-questions

tech-interview-handbook's Introduction

Tech Interview Handbook


Start Reading Tech Interview Handbook

What is this?

Not everyone has the time to do a few hundred LeetCode questions. Here are free and curated technical interview preparation materials for busy engineers, brought to you by me, the author of Blind 75. Over 500,000 people have benefitted from this handbook!

Besides the usual algorithm questions, other awesome stuff includes:

Help from you in contributing content would be very much appreciated!

Why would you read this?

This repository has practical content that covers all phases of a technical interview, from applying for a job to passing the interviews to offer negotiation. Technically competent candidates might still find the non-technical content helpful.

The information in this repository is condensed. Ultimately, the key to succeeding in technical interviews is consistent practice and I don't want to bore you with too many words. I tell you the minimum you need to know on how to go about navigating the interview process, you go and practice and land your dream job.

Who is this for?

Anybody who wants to land a job at a tech company but is new to technical interviews, seasoned engineers who have not been on the other side of the interviewing table in a while and want to get back into the game, or anyone who wants to be better at technical interviewing.


💡 Stop grinding mindlessly! Study coding question patterns efficiently with Grokking the Coding Interview by Design Gurus 💡


How is this repository different?

There are many awesome books like "Cracking the Coding Interview" and interview-related repositories out there on GitHub, what makes this repository different? The difference is that many existing interview repositories contain mainly links to external resources whereas this repository contains top-quality curated content directly for your consumption.

Also, existing resources focus mainly on algorithm questions and lack coverage for more domain-specific and non-technical questions. This handbook aims to cover content beyond the typical algorithmic coding questions. 😎

Looking for interview courses?

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 →

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! Get lifetime access today →

Looking for Front End content?

Front-end-related content has been moved to a separate website - Front End Interview Handbook.

Looking for System Design content?

We're still working on System Design content. In the meanwhile, check out ByteByteGo's System Design Interview course or Design Gurus' Grokking the System Design Interview course, which in our opinion are among the most useful resources for getting started on system design interviews preparation.

Contents

A Docusaurus website has been created to provide a better reading experience. Check out the website here!


💡 Stop the grind and study with a plan! Developed by Google engineers, AlgoMonster is the fastest way to get a software engineering job. Join today for a 70% discount! 💡


Related

If you are interested in how data structures are implemented, check out Lago, a Data Structures and Algorithms library for JavaScript. It is pretty much still WIP but I intend to make it into a library that can be used in production and also a reference resource for revising Data Structures and Algorithms.

Contributing

There are no formal contributing guidelines at the moment as things are still in flux and we might find a better approach to structure content as we go along. You are welcome to contribute whatever you think will be helpful to fellow engineers. If you would like to contribute content for different domains, feel free to create an issue or submit a pull request and we can discuss further.

Contributors

This project exists thanks to all the people who contributed. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

Buy Me A Coffee

Sponsors

Support this project by becoming a sponsor. Your logo/profile picture will show up here with a link to your website. [Become a sponsor]

Disclaimer

I am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my code is from me and not my employer (Meta).

tech-interview-handbook's People

Contributors

ailing35 avatar albanie avatar alexprut avatar bryannyeap avatar dependabot[bot] avatar doraemonx avatar hpkoh avatar jeffsieu avatar jorgegonzalez avatar keanecjy avatar li-kai avatar louietyj avatar mehrdadrafiee avatar nicholaslee119 avatar nisarhassan12 avatar pandanoodles418 avatar peironggg avatar polizz avatar quanyang avatar rockalife avatar s7u4rt99 avatar tnsyn avatar vielheim avatar waniniraj avatar weehongayden avatar wlren avatar xhmikosr avatar yangshun avatar yaodingyd avatar ziqing26 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tech-interview-handbook's Issues

Kadane's algorithm implementation

Can I contribute a .cpp file explaining kadane's algorithm implementation and required comments for the maximum contiguous subarray sum problem. I saw the maximum contiguous subarray sum problem on the site . So people can see it's solution on the repo.

Future Content Roadmap

Umbrella issue to house plans for adding more content to the handbook which would be useful to job seekers.

Off the top of my head, I have the following ideas in mind:

Feel free to contribute ideas!

Checklist in place of Bullet Points

I think using a checklist to display all the weekly problems would be more helpful. The user can mark the problems which he/she already knows.

Adding a list of practice sites

Hello,

This repository is great! Thanks for sharing this. I had created a github repo that lists all the various websites where people can practice algorithmic questions typically asked in interviews. It was initially for myself and then I decided to open-source it. I would like to add a reference to this repository here so, it could be helpful to the community as well. I feel it is aptly suited under the preparing section in your repository.

Let me know if this sounds good, I will raise a PR for this change!

Thanks,
Harshita Kasera

[future content] Team Selection

This is an issue to start collecting ideas on a page on team selection.

Goal

Help candidates to evaluate teams in their new company and what factors they need to take into account.

Resources

TODO

Algorithms string: "redblueredblue"

Great guide!
I think I might have found an error there: string.md
E.g. "abba" and "redblueredblue" should return true
It should either be: "return false" or "redbluebluered" according to the given pattern.

Add links to Design Gurus' courses?

Instead of paying a subscription for "Grokking the System Design Interview by Educative", people can also pay for lifetime access for the same course from Design Gurus (along with others). This might be an option people want to consider when paying for a course.

Resources for folks on the other side of the table?

This is an awesome resource for people looking to polish their skills for when they go into interviews.

Are there any plans to add some resources for the interviewers? IE, the brand new tech lead who needs to hire a junior but has no idea what kinds of questions to ask, or the manager who doesn't know a ton but needs to find just the right dev for their open position.

Convert to Superbook

Really great resource, thanks for sharing!

A few of us like to read and remember better with codex style Superbook [1] format. I can convert and publish it for you using a script in a weekend if you want.

[1] https://bubblin.io/docs/format

Add solution to a leetcode problem.

Problem: https://leetcode.com/problems/sum-root-to-leaf-numbers/

Solution Explanation Blog Post: https://medium.com/leetcode-solutions/summing-root-to-leaf-numbers-in-a-binary-tree-353f33c8565e

Solution Explanation Text:

Summing Root to Leaf Numbers in a Binary Tree

leetcode1

Sum Root to Leaf Numbers is an interesting problem from Leetcode. The problem is of medium difficulty and is about binary trees. This post presents and explains the solution along with the thought process.

I assume that you’re familiar with Python and the concept of binary trees. If you’re not, you can read this article to get started.

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:

leetcode2

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 sum of the three numbers 495, 491 and 40.

The Observations and Insights

  • We notice that we traverse the tree from the root to the leaf, visiting some leaves before many of the direct children of the root itself. This suggests that a depth-first search might be more useful here, and especially the one which starts visits the root first.

  • We notice that the building of numbers is incremental and similar of sorts: the only difference between 495 and 491 is the last digit. If we remove the 5 and insert a 1 in its place, we have the next number. A number is essentially made of up all digits in its ancestor nodes and thus shares many digits with siblings and nodes within the same sub-tree.

  • Finally, we notice that this problem involves a tree so a recursive solution is possible and natural.

The Solution

We can do a pre-order traversal of the tree where we incrementally build up a number and exploit the fact that numbers formed by nodes in the same sub-tree have common digits for common ancestors. When we’re done forming numbers in a sub-tree, we can back-track and go to another sub-tree.

Let’s create a Solution class to encompass our solution. We can have an array attribute to store all the root-to-leaf numbers formed and an array attribute to store the current list of digits as we traverse the tree.

class Solution: 
    curr = [] # stores digits in the current path 
    numbers = [] # stores numbers formed by root-to-leaf paths
    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):

class TreeNode:
     def __init__(self, val=0, left=None, right=None):
         self.val = val
         self.left = left
         self.right = right

As highlighted earlier, we need to build a number for each root-to-leaf path so that we can compute the sum of all numbers. To keep our code modular, let’s define another method to do this (instead of doing it within the sum_numbers method). This method will be responsible for filling our numbers array with all the root-to-leaf numbers. Let’s call it get_root_to_leaf_nums. It should take an argument of type TreeNode as well and return nothing (since it is modifying state by filling up the numbers array.

Our Solution class looks like:

class Solution: 
    curr = []
    numbers = []
    def sum_numbers(self, root: TreeNode) -> int:
    def get_root_to_leaf_nums(self, root: TreeNode): 

We can think of the get_root_to_leaf_nums method recursively and process each node differently based on whether it is a leaf or a not a leaf.

  • If it is a leaf, we want to add the value to our curr array, create a number based on the digits in the curr array and add the number to the numbers array. Since the node is a leaf, we will backtrack from here to the previous node and therefore want to delete the current node’s value from the curr array.

  • If it is not a leaf, we want to add the value to our curr array, and then continue traversing the left and right sub-trees. When done, we want to remove the current node’s value from the curr array as we backtrack.

Thus, our get_root_to_leaf_nums method will be as follows:

def get_root_to_leaf_nums(self, root: TreeNode): 
        if root: 
            self.curr.append(str(root.val))
            if not root.left and not root.right:
                self.numbers.append(self.convert_to_num(self.curr))
                self.curr.pop()
            else: 
                self.get_root_to_leaf_nums(root.left)
                self.get_root_to_leaf_nums(root.right)
                self.curr.pop()

We check if the root is not a None and simply do nothing if it is None as we are not concerned with empty sub-trees. We need a convert_to_num method that can convert the curr array representing digits of the number to an integer:

def convert_to_num(self, arr) -> int:
        cum = int("".join([str(x) for x in arr]))
        return int(cum)

We basically convert each int in the curr array to a string, concatenate the string and then typecast the result back to an int.

Now, in our main method, we first want to fill the numbers array and then simply return its sum. We need to clear the numbers array at the end because Leetcode will typically run this through a lot of testcases and subsequent testcases will fail if the numbers array contains solutions numbers from a previous testcase.

Finally, this is how our solution looks:

class Solution: 
    curr = []
    numbers = []
    def sum_numbers(self, root: TreeNode) -> int:
        #get all numbers from root to leaf paths
        self.pre_order(root)
        # sum all numbers
        ans = sum(self.numbers)
        self.numbers.clear()
        return ansdef get_root_to_leaf_nums(self, root: TreeNode): 
        if root: 
            self.curr.append(str(root.val))
            if not root.left and not root.right:
                self.numbers.append(self.convert_to_num(self.curr))
                self.curr.pop()
            else: 
                self.get_root_to_leaf_nums(root.left)
                self.get_root_to_leaf_nums(root.right)
                self.curr.pop()def convert_to_num(self, arr) -> int:
        cum = int("".join([str(x) for x in arr]))
        return int(cum)

The Algorithmic Complexity

When solving a problem, 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.

Time:

Our solution is a modification of the depth-first-search pre-order traversal where we visit all nodes exactly once. Thus, our runtime is simply O(N) where N represents the number of nodes in the given tree. I can’t think of a solution that will be better than O(N) because to construct a number from digits, I need to know all the digits.

We also incur a small cost to sum the numbers in the numbers list and to convert the curr array to an integer, but these costs are insignificant when compared to the cost of visiting each node (the number of numbers formed will be less than total number of nodes).

Space:

In terms of storage, we store the numbers formed and the current list of digits, which is not that significant. However, what is significant is the recursion call stack that builds up as our get_root_to_leaf_nums calls itself. These calls “build-up” as one waits for another to finish.

Generally, the maximum call stack will be 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(H).

You can read this article to know more about recursion call stacks.

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.

Fixing Link on website

On the tech interview handbook website, under the algorithms>Dynamic Programming>Recommended Leetcode questions, the 0/1 Knapsack Problem does not link to a page. Request to assign this issue to me so I can fix it.

[future content] Engineering Levels

This is an issue to start collecting ideas on a page on engineering levels.

Goal

Help candidates know what is expected of levels at various companies to better determine the engineering level they should be at and making sure they're getting a fair offer

Resources

Gender inclusive?

You speak about shirt and tie. Now of course there's nothing stopping a woman from wearing that, but wouldn't you agree that this makes it sound like you're only addressing a male audience?

question

I'm confused by the new Study and Practice Plan format.

The recommended questions from weeks 1-4 are also found in the later weeks.
So should we not solve those recommended problems in those initial 4 weeks, and just read through the concepts?

Screen Shot 2022-04-20 at 9 24 06 PM

Screen Shot 2022-04-20 at 9 20 47 PM

Feature Request: Buttons for collapse all/expand all on the Grind75 site

A collapse all/expand all buttons will really improve UX because on first load, every weekly problem group on Grind75 page is expanded, which makes it a little bit cumbersome to scroll down to Week 6+, and there are no easy ways to collapse all either.

Therefore, I believe having collapse all/expand all buttons along with starting in Collapsed mode would be better

I will be happy to contribute PRs to code (I want to contribute to OSS too) if someone can point me to right file and folder.

Convert to PDF

Any plans on being able to clone the repo and building a PDF out of it?

Contribute your success stories/testimonials to be featured!

Feel free to contribute success stories/testimonials to the website! If this repository has helped you with your job hunt and you would like to put in a good word for the repo and be featured on the front page of the website, please comment down below! If there are too many submissions, I'll create a separate page to include them.

If interested, please submit the following:

Submit them here

I am new to java, can anyone help me debug my code?

public class Ferry
{
private Vehicle[] ferry;
private int numVehicle;
private int maxVehicle;
private int maxAxel;
private int maxPassenger;
private double weightLimit;
private double weight = 0;
private int numAxel = 0;
private int numPassenger = 0;

public Ferry(int maxVehicle, int maxAxel, int maxPassenger, double weightLimit)
{
	
	ferry = new Vehicle[maxVehicle];
	numVehicle = 0;
	

}



public boolean addVehicle(Vehicle v)
{
	boolean added = false;
	if(numVehicle < ferry.length)
	{
		boolean found = false;
		for(int i=0;i<numVehicle && !found;i++)
		{
			if(v.getIdNum() == ferry[i].getIdNum()){
			found = true;
			}
		}
		return found;
		
	
		if(!found)
		{
			if(weight<weightLimit) 
			{
				if(numAxel<maxAxel)
				{
					if(numPassenger<maxPassenger)
					{
						ferry[numVehicle] = v;
						numVehicle++;
						numAxel += v.getNumAxel();
						numPassenger += v.getNumPassenger();
						weight += v.getWeight();
						added = true;

					}
					
				}
			}

		}
	
	}
	return added;
}



//removing vehicle

public boolean removeVehicle(Vehicle v){
	boolean removed = false; 
	for (int i = 0; i<numVehicle && !removed; i++) 
	{
		if (v.getIdNum() == ferry[i].getIdNum()) 
		{
			ferry[i] = ferry[numVehicle - 1];
			numVehicle--;
			numAxel -= v.getNumAxel();
			numPassenger -= v.getNumPassenger();
			weight -= v.getWeight();
			removed = true;
		}
	}
	
	return removed;


}


public boolean changeNumPass(Vehicle v,int  newNumPassenger)
{
	boolean changed = false;
	if(numVehicle < ferry.length)
	{
		
		for(int i=0;i<numVehicle && !found;i++)
		{
			if(v.getIdNum() == ferry[i].getIdNum())
			{
				if((numPassenger-v.getNumPassenger()+newNumPassenger) < maxPassenger)
				{
					v.setNumPassenger(newNumPassenger);
					numPassenger = numPassenger - v.getNumPassenger()+newNumPassenger;
					changed = true;

				}

			}
			
		}
	
	}
	return changed;


}

}

A messaging bot for tech-interview-handbook

I have developed an AI Bot that can assist users in Interview Preparation by using the content from tech-interview-handbook by yangshun. I'm ready to send pull request if you're interested in this idea.

Alternative to Lago?

Suggestion to replace the link to Lago (under Interview Process -> Coding round -> Study and practise) with TheAlgorithms as it contain data structures and algorithms implemented in many more languages (Java, Javascript, Python, C, C++ etc) compared to Lago which focuses only on js.
I can go ahead with a pull request for this if thats okay.

Found 2 typos.

  1. Found a typo in tech-interview-handbook/blob/master/preparing/README.md on line 70.
    Typo - oppurtunities.

  2. Found a typo in tech-interview-handbook/blob/master/interviewers/basics.md on line 19.
    Typo - psuedocode.

Possible error in tree section

Thanks for this really helpful guide! In your tree section, it says that "When you are asked to traverse a tree by level, use depth first search." In this case, should it be Breadth First Search? I remember doing a Level-Order traversal problem on LeetCode, and to solve it I used BFS with a queue. I think I may be misreading your statement too.

TSF

من میخواهم عضو تیم پشتیبانی شوم لطفا راهنمایی کنیدمن را

Combination Sum links to Combination Sum IV

In the Best Practice Questions section under Week 5 – Dynamic Programming, Combination Sum linked to LeetCode Combination Sum IV. Is this intended? All other questions have the correct numbering (e.g. Word Search II).

Add Twitter testimonials

I need

file:///var/mobile/Library/SMS/Attachments/dc/12/2664D2DB-9B41-4D25-AFA2-445ECB8F22D0/takeout-20220125T041706Z-001.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.