- [Grokking the Coding Interview: Patterns for Coding Questions](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W) - This course essentially expands upon the questions on this page but approaches the practicing from a questions pattern perspective rather than data structures, which is an approach I also agree with for learning and have personally used to get better at algorithmic problems. **Learn and understand patterns, not memorize answers!**
- [Master the Coding Interview: Data Structures + Algorithms](https://fxo.co/DQoD) - 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!
- [Grokking the Dynamic Programming Patterns for Coding Interviews](https://www.educative.io/courses/grokking-dynamic-programming-patterns-for-coding-interviews?aff=x23W)
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
- [Graph Valid Tree (LeetCode Premium)](https://leetcode.com/problems/graph-valid-tree/)
- [Graph Valid Tree (LeetCode Premium)](https://leetcode.com/problems/graph-valid-tree/)
- [Number of Connected Components in an Undirected Graph (LeetCode Premium)](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/)
- [Number of Connected Components in an Undirected Graph (LeetCode Premium)](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/)
## Recommended courses
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
- Describe an implementation of a least-used cache, and big-O notation of it.
- 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.
- A question involving an API's integration with hash map where the buckets of hash map are made up of linked lists.
- Implement data structure `Map` storing pairs of integers (key, value) and define following member functions in O(1) runtime: `void insert(key, value)`, `void delete(key)`, `int get(key)`, `int getRandomKey()`. [(Solution)](http://blog.gainlo.co/index.php/2016/08/14/uber-interview-question-map-implementation/)
- Implement data structure `Map` storing pairs of integers (key, value) and define following member functions in O(1) runtime: `void insert(key, value)`, `void delete(key)`, `int get(key)`, `int getRandomKey()`. [(Solution)](http://blog.gainlo.co/index.php/2016/08/14/uber-interview-question-map-implementation/)
## Recommended courses
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
description: Here are practical tips for each algorithm topic and data structure which appear frequently in coding interviews
sidebar_label: Introduction
sidebar_label: Introduction
slug: introduction
slug: introduction
---
---
@ -46,13 +47,15 @@ Hashmaps are probably the most commonly used data structure for algorithm questi
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.
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.
## Algorithm courses
## Recommended courses
If you want more structured algorithms practice, I recommend [Educative's Grokking the Coding Interview: Patterns for Coding Questions](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W) course. This course essentially expands upon the questions here but approaches the practicing from a questions pattern perspective rather than data structures, which is an approach I agree with for learning and getting better at algorithmic problems.
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
## References
<AlgorithmCourses/>
<!-- ## References
- [Educative's Grokking the Coding Interview: Patterns for Coding Questions](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W)
- [Educative's Grokking the Coding Interview: Patterns for Coding Questions](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W)
@ -23,7 +23,7 @@ Two pointer approaches are also common for linked lists. For example:
- 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
- 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
- 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
## Common Routines
## 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:
Be familiar with the following routines because many linked list questions make use of one or more of these routines in the solution:
@ -46,3 +46,9 @@ Be familiar with the following routines because many linked list questions make
- [Merge K Sorted Lists](https://leetcode.com/problems/merge-k-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/)
- [Remove Nth Node From End Of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/)
- Implement a Queue class from scratch with an existing bug, the bug is that it cannot take more than 5 elements.
- Implement a Queue class from scratch with an existing bug, the bug is that it cannot take more than 5 elements.
- Implement a Queue using two stacks. You may only use the standard `push()`, `pop()`, and `peek()` operations traditionally available to stacks. You do not need to implement the stack yourself (i.e. an array can be used to simulate a stack).
- Implement a Queue using two stacks. You may only use the standard `push()`, `pop()`, and `peek()` operations traditionally available to stacks. You do not need to implement the stack yourself (i.e. an array can be used to simulate a stack).
## Recommended courses
import AlgorithmCourses from '../\_courses/AlgorithmCourses.md'
import AlgorithmCourses from './\_courses/AlgorithmCourses.md'
<head>
<head>
<title>Best practice questions by the author of Blind 75 | Tech Interview Handbook</title>
<title>Best practice questions by the author of Blind 75 | Tech Interview Handbook</title>
<metaproperty="og:title"content="Best practice questions by the author of Blind 75 | Tech Interview Handbook"/>
<metaproperty="og:title"content="Best practice questions by the author of Blind 75 | Tech Interview Handbook"/>
@ -23,6 +25,12 @@ When practicing, you are advised to treat it like a real coding interview and ch
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.
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
If you're running low on time, the [Grokking the Coding Interview: Patterns for Coding Questions](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W) course essentially expands upon the questions on this page but approaches the practicing from a questions pattern perspective rather than data structures. **Learn and understand patterns, not memorize answers!**
:::
## Week 1 - Sequences
## 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.
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.
@ -130,4 +138,4 @@ Practically speaking the return of investment (ROI) on studying and practicing f
If you want more structured algorithms practice, I recommend the following courses:
If you want more structured algorithms practice, I recommend the following courses:
- ["Grokking the Coding Interview: Patterns for Coding Questions" by Educative](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W) - This course essentially expands upon the questions on this page but approaches the practicing from a questions pattern perspective rather than data structures, which is an approach I also agree with for learning and have personally used to get better at algorithmic problems. **Learn and understand patterns, not memorize answers!**
description: Mastery of Computer Science fundamentals, identifying question patterns, practicing good coding style is the key to improving in coding interviews
description: Mastery of Computer Science fundamentals, identifying question patterns, practicing good coding style is the key to improving in coding interviews
keywords:
keywords:
[
[
@ -23,11 +23,7 @@ keywords:
If you have been out of college for a while, it is highly advisable to review Computer Science fundamentals—Algorithms and Data Structures. Personally, I prefer to review as I practice, so I scan through my college notes and review the various algorithms as I work on algorithm problems from LeetCode.
If you have been out of college for a while, it is highly advisable to review Computer Science fundamentals—Algorithms and Data Structures. Personally, I prefer to review as I practice, so I scan through my college notes and review the various algorithms as I work on algorithm problems from LeetCode.
This [interviews repository](https://github.com/kdn251/interviews) by Kevin Naughton Jr. served as a quick refresher for me.
I collated a list of practical tips for the common algorithm and data structure topics under the [Algorithms tips](./algorithms/introduction) section.
The Medium publication [basecs](https://medium.com/basecs) by [Vaidehi Joshi](https://medium.com/@vaidehijoshi) is also a great and light-hearted resource to recap on the various data structures and algorithms.
You can also find implementations of common data structures and algorithms using various popular languages at [TheAlgorithms](https://thealgorithms.github.io/).
## Mastery through practice
## Mastery through practice
@ -35,15 +31,17 @@ Next, gain familiarity and mastery of the algorithms and data structures in your
### Practice coding questions
### Practice coding questions
Practice coding algorithms using your chosen language. While "Cracking the Coding Interview" is a good resource for practice, I prefer being able to type code, run it and get instant feedback. There are various Online Judges such as [LeetCode](https://leetcode.com/), [HackerRank](https://www.hackerrank.com/) and [CodeForces](http://codeforces.com/) for you to practice questions online and get used to the language. From experience, LeetCode questions are the most similar to the kind of questions being asked in interviews whereas HackerRank and CodeForces questions resemble competitive programming questions. If you practice enough LeetCode questions, there is a good chance that you would have seen/done your actual interview question (or some variant) on LeetCode before. If you are more of a visual person, [Coderust](https://www.educative.io/collection/5642554087309312/5679846214598656?aff=x23W) explains the common algorithm questions through step-by-step visualizations which makes understanding the solutions much easier.
Practice coding algorithms using your chosen language. While "Cracking the Coding Interview" is a good resource for studying, I prefer being able to type code, run it and get instant feedback. There are various Online Judges such as [LeetCode](https://leetcode.com/), [HackerRank](https://www.hackerrank.com/) and [CodeForces](http://codeforces.com/) for you to practice questions online and get used to the language. From experience, LeetCode questions are the most similar to the kind of questions being asked in interviews whereas HackerRank and CodeForces questions resemble competitive programming questions. If you practice enough LeetCode questions, there is a good chance that you would have seen/done your actual interview question (or some variant) on LeetCode before.
If you are more of a visual person, [Coderust](https://www.educative.io/collection/5642554087309312/5679846214598656?aff=x23W) explains the common algorithm questions through step-by-step visualizations which makes understanding the solutions much easier.
### Broaden exposure
### Broaden exposure
Gain a broad exposure to questions from various topics. In the second half of the article I mention algorithm topics and practice questions for each topic. If you can spare the time, do around 100–200 LeetCode questions of varying topics and you should be good. If you are short on time or not sure where to start, the [Best Practice Questions](./best-practice-questions.md) page tells you the best LeetCode questions to practice.
Gain a broad exposure to questions from various topics. If you can spare the time, do around 100–200 LeetCode questions of varying topics and you should be good. If you are short on time or not sure where to start, the [Best practice questions](./best-practice-questions.md) page recommends you the best 50 LeetCode questions to practice.
### Identify question patterns
### Identify question patterns
As of writing, LeetCode has thousands of questions available. Which should you practice? It is not a good use of time to practice too many questions as after a while, you will realize that some questions are variants of one another and involve using similar techniques you've seen before. The trick here is to identify the question pattern and the technique you can use to solve variants of this question. Once you're familiar with a pattern, you'll be able to solve dozens of problems with a technique. Some techniques include - sliding window, two pointers, matrix traversal. The ["Grokking the coding interview" course by Educative](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W) shows you more techniques.
As of writing, LeetCode has thousands of questions available. Which should you practice? It is not a good use of time to practice too many questions as after a while, you will realize that some questions are variants of one another and involve using similar techniques you've seen before. The trick here is to identify the question pattern and techniques you can use to solve variants of this question. Once you're familiar with a pattern, you'll be able to solve dozens of similar problems. Some techniques include - sliding window, two pointers, matrix traversal. The ["Grokking the Coding Interview: Patterns for Coding Questions" course by Educative](https://www.educative.io/courses/grokking-the-coding-interview?aff=x23W) shows you even more techniques and is highly recommended.
:::tip Expert tip
:::tip Expert tip
@ -53,14 +51,24 @@ Learn and understand patterns, not memorize answers!
### Space/time complexities
### Space/time complexities
Learn and understand the time and space complexities of the common operations in your chosen language. For Python, this [page](https://wiki.python.org/moin/TimeComplexity) will come in handy. Also find out the underlying sorting algorithm that is being used in the language's `sort()` function and its time and space complexity (in Python its Timsort which is a hybrid sort). After completing a question on LeetCode, I usually add the time and space complexities of the written code as comments above the function body to remind myself to analyze the algorithm after I am done with the implementation.
Learn and understand the time and space complexities of the common operations in your chosen language. For Python, this [page](https://wiki.python.org/moin/TimeComplexity) will come in handy. Also find out the underlying sorting algorithm that is being used in the language's `sort()` function and its time and space complexity (e.g. in Python it's Timsort, which is a hybrid sort). After completing a question on LeetCode, I usually add the time and space complexities of the written code as comments above the function body to remind myself to analyze the algorithm after I am done with the implementation.
### Practice good coding style
### Practice good coding style
Read up on the recommended coding style for your language and stick to it. If you have chosen Python, refer to the PEP 8 Style Guide. If you have chosen Java, refer to Google's Java Style Guide.
Read up on the recommended coding style for your language and stick to it. If you have chosen Python, refer to the [PEP 8 Style Guide](https://www.python.org/dev/peps/pep-0008/). If you have chosen Java, refer to [Google's Java Style Guide](https://google.github.io/styleguide/javaguide.html).
### Internalize the pitfalls
### Internalize language pitfalls
Find out and be familiar with the common pitfalls and caveats of the language. If you point them out during the interview and intelligently avoid falling into them, you will usually impress the interviewer and that results in bonus points for your feedback, regardless of whether the interviewer is familiar with the language or not.
Find out and be familiar with the common pitfalls and caveats of the language. If you point them out during the interview and intelligently avoid falling into them, you will usually impress the interviewer and that results in bonus points for your feedback, regardless of whether the interviewer is familiar with the language or not.
**The key to interview success is practice, practice and more practice!**
:::tip
The key to interview success is practice, practice and more practice!
:::
## External resources
- This [interviews repository](https://github.com/kdn251/interviews) by Kevin Naughton Jr. served as a quick refresher for me.
- The Medium publication [basecs](https://medium.com/basecs) by [Vaidehi Joshi](https://medium.com/@vaidehijoshi) is also a great and light-hearted resource to recap on the various data structures and algorithms.
- You can also find implementations of common data structures and algorithms using various popular languages at [TheAlgorithms](https://thealgorithms.github.io/).