--- image: https://i.imgur.com/tFW9IxW.png --- # Preparing for Technical Interviews Many technical interviews tend to involve being asked coding questions and then having to solve them. This typically involves working knowledge of data structures and algorithms. ## Getting Started ### What are "data structures and algorithms"? Data structures are just different ways or organizing and storing data within code. Examples of these are: Array, Linked Lists, Stack, Queues, Trees, Graphs, Sets, Hash Tables. Algorithms are simply a particular approach to solving a problem with code. Algorithms involve writing lines of code which often access data structures and then performs operations and calculations on the data (sorting, searching, adding, removing, etc). Used together, you can select one or more data structures to store your data, and then use particular algorithms to achieve a particular goal or solution within your software programs. For example, you might be asked to "reverse a linked list" or "sort an array of numbers" which combines a data structure (linked list or array) with an algorithm (reverse or sort). ### How should I study for technical interviews? Generally, studying for technical interviews involves the following steps: 1. Buy a book like [Cracking the Coding Interview](https://www.amazon.com/Cracking-Coding-Interview-Programming-Questions/dp/0984782850) and others recommended below. 1. Learn about the [specific steps you should be taking in a coding interview](https://hackmd.io/s/SJye97LTQ) 1. Learn about the major data structures and the most common algorithms via videos, written guides, books 1. Practice easy problems online coding solutions to various problems that involve different data structures and algorithms you've read about 1. Learn about Big-O notation and how to evaluate how efficient your solution is 1. Review optimized solutions available to see how you can improve your solutions 1. Repeat. Practice more. Repeat again. Lots of repeating. Be aware that there are many different data structures and algorithms, and many different difficulty levels of problems ranging from relatively straightforward to very advanced techniques. :::warning Becoming confident and proficient in the full range of common interview questions could take months of studying and hundreds of hours. **Don't get discouraged, be patient and remember to take things one step at a time**. ::: ### How does a coding interview usually work? Check out our guide here for a [detailed breakdown of how interviews work](https://tinyurl.com/codepathinterviewguide). There are [specific steps to how to tackle a problem](https://hackmd.io/s/SJye97LTQ) during a coding interview which should review carefully and practice. ## Core Topics for Review The following topics tend to be encountered most often in coding interviews broken up into multiple levels. Do not attempt to review all of them at once, instead study a few and then do some practice problems with them on sites linked later in this guide. If you are looking for introductions to these concepts that are fun and accessible, check out [BaseCS](https://hackmd.io/s/HJ9YQDE2b) and the [related podcast](https://www.codenewbie.org/basecs). You can also read through this [algorithms tutorial series](https://adrianmejia.com/blog/2018/04/04/how-you-can-change-the-world-learning-data-structures-algorithms-free-online-course-tutorial/). **Level 1** * Basic data structures I: [Hash Tables](https://www.interviewcake.com/concept/hash-map), [Stacks](https://www.interviewcake.com/concept/stack), [Queues](https://www.interviewcake.com/concept/queue) **Level 2** * Basic data structures II: [Linked Lists](https://www.interviewcake.com/concept/linked-list), [Arrays](https://www.interviewcake.com/concept/array), [Strings](https://medium.com/modernnerd-code/java-for-humans-string-manipulation-5573acac6aa5) * Complexity Analysis: [Big-O Notation](https://www.interviewcake.com/big-o-notation-time-and-space-complexity) **Level 3** * Traversal data structures: [Binary Trees](https://www.interviewcake.com/concept/binary-tree), [Graphs](https://www.interviewcake.com/concept/graph) * Searches: [Binary Search](https://www.interviewcake.com/concept/binary-search), [Breadth First Search](https://www.interviewcake.com/concept/bfs)/[Depth First Search](https://www.interviewcake.com/concept/dfs) **Level 4** * Advanced I: [Recursion, Backtracking and Combinatorials](https://www.interviewcake.com/concept/java/bottom-up) * Advanced II: [Dynamic Programming](https://www.interviewcake.com/concept/overlapping-subproblems) and [Greedy Algorithms](https://www.interviewcake.com/concept/greedy) Check the books and links below for more resources to use while practicing and learning data structures and algorithms. ## Buy a Book: Cracking The Coding Interview If you only want one book for technical interview prep, download [Cracking The Coding Interview](https://github.com/sunilsoni/Interview-Preparation/raw/master/books/Cracking%20the%20Coding%20Interview%2C%206th%20Edition%20189%20Programming%20Questions%20and%20Solutions.pdf) or [buy the book on Amazon](https://www.amazon.com/Cracking-Coding-Interview-Programming-Questions/dp/0984782850). - The "Before the Interview" section goes over resume tips, common non-technical questions you may be asked, and an overview of the technical topics you want to familiarize yourself with. - The "Interview and Beyond" section has general strategies for how to approach the interview, solving technical questions, and negotiating once you get an offer. (We highly recommend reviewing this section). - The rest of the book is the interview questions split into different sections based on topic, focus on the topics you’re least comfortable with. For intern/new grad applicants, I’d recommend prioritizing Chapters 1-4, 8, 9, and 11 since those sections cover the core topics. If you are looking for additional books that are complementary to CTCI, we recommend: * [Algorithms to Live By: The Computer Science of Human Decisions](https://www.amazon.com/Algorithms-Live-Computer-Science-Decisions/dp/1250118360) - This is more of a casual look and more "fun" then CTCI * [The Algorithm Design Manual](https://www.amazon.com/Algorithm-Design-Manual-Steven-Skiena/dp/1849967202/) - Great for interview prep but also more in-depth and better at painting the big picture. Also provides interesting real life case studies of certain algorithms and data structures. * [Introduction to Algorithms](https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press/dp/0262033844) - This is not as accessible to newcomers or beginners, but if you want a comprehensive and exhaustive algorithms bible, this is the book for you! ## Practicing Problems You can review and practice problems at all these websites below: - [Leetcode](https://leetcode.com/): LeetCode is a great platform to help you enhance your skills, expand your knowledge and prepare for technical interviews. - [InterviewBit](https://interviewbit.com) - Online site for practicing interview questions - [Firecode.io](https://www.firecode.io/): For daily technical interviews practice which incorporates fundamentals. - [HackerRank](https://www.hackerrank.com/):Leading end-to-end technical recruiting platform for hiring engineers. - [Career Cup](https://www.careercup.com/page): Peers post interview questions they have been asked, and other can contribute their own answers to these questions. A major goal of this website is to give users an inside look at the interview process of different companies.   They also offer a mock interview service. - [Project Euler](https://projecteuler.net/): Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. - [Python Tutor](http://pythontutor.com/visualize.html#mode=edit): Python Tutor helps students overcome a fundamental barrier to learning programming: understanding what happens as the computer runs each line of source code. Visualize Python, Java, JavaScript, TypeScript, and Ruby code execution. You can practice interviewing on a video chat with: - [Pramp](https://www.pramp.com/#/) - Practice coding interviews live! - [Interviewing.io](https://interviewing.io/): Free, anonymous technical interview practice with engineers. ----- # Even More Resources :information_source: Below is an even longer list of resources you can check out: ## Courses * [Udacity Interview Course](https://www.udacity.com/course/technical-interview--ud513) * [Cousera Interview Course](https://www.coursera.org/learn/introduction-to-algorithms) * [10 Suggested Courses on the Coding Interview](https://hackernoon.com/10-data-structure-algorithms-and-programming-courses-to-crack-any-coding-interview-e1c50b30b927) ## Articles * [Ace the coding interview, every time](https://medium.com/@nickciubotariu/ace-the-coding-interview-every-time-d169ce1fd3fc#.3w767vppf) * [Get That Job at Google](http://steve-yegge.blogspot.com/2008/03/get-that-job-at-google.html) ## Cheat Sheets * [Google Interview University](https://github.com/jwasham/google-interview-university) * [Tech Interview Cheat Sheet](https://gist.github.com/TSiege/cbb0507082bb18ff7e4b) * [Algorithms, Data Structures, & Big O Cheat Sheet](http://cooervo.github.io/Algorithms-DataStructures-BigONotation/) * [Big O Cheat Sheet](http://bigocheatsheet.com/) * [Princeton Algorithms and Data Structures Cheat Sheet](http://algs4.cs.princeton.edu/cheatsheet/) * [Algorithmic Cheat Sheet](https://sinon.org/algorithms/#data-structures) ## Explainers * Big O & Complexity Analysis * [Big O Notation](https://www.interviewcake.com/article/java/big-o-notation-time-and-space-complexity) * [The Idiots Guide to Big O](http://www.corejavainterviewquestions.com/idiots-guide-big-o/) * Java * [Guide to Selecting Appropriate Map/Collection in Java](http://www.sergiy.ca/guide-to-selecting-appropriate-map-collection-in-java/) * Visualizations * [VisuAlgo](http://visualgo.net/) - visualising data structures and algorithms through animation * [15 Sorting Algorithms in 6 Minutes](https://www.youtube.com/watch?v=kPRA0W1kECg) * [Data Structure Visualizations](https://www.cs.usfca.edu/~galles/visualization/Algorithms.html) * [Sorting Algorithms Animations](https://www.toptal.com/developers/sorting-algorithms/#) ## Code * [Algorithms and Data Structures implemented in Java](https://github.com/phishman3579/java-algorithms-implementation) ## Books * [Elements of Programming Interviews](https://www.amazon.com/Elements-Programming-Interviews-Insiders-Guide/dp/1479274836) * [Algorithms (4th Edition)](http://www.amazon.com/gp/product/032157351X/) * [Algorithms in a Nutshell](https://www.amazon.com/Algorithms-Nutshell-OReilly-George-Heineman/dp/059651624X) ## Concept Overview The "computer science" technical interviews are probably one of the most important parts of getting a job at a company like Facebook, Google, or Microsoft. You need to understand them to be prepared for an interview. Studying for these problems is the best way to become comfortable enough to be able to solve challenges they throw at you. These questions are about topics such as: - Data Structures (Linked List, Binary Tree, Graphs) - Data Traversal and Manipulation (Sorting, Constructing) - String and Token Parsing - Array Manipulation - Regular Expressions - Combinatorial Sets or Permutations - Recursive Algorithms Here's a few specific topics in-more depth to ensure you are familiar with (sourced from [this article](http://steve-yegge.blogspot.com/2008/03/get-that-job-at-google.html)): - **Algorithm Complexity**: you need to know Big-O. It's a must. If you struggle with basic big-O complexity analysis, then you are almost guaranteed not to get hired. It's, like, one chapter in the beginning of one theory of computation book, so just go read it. You can do it. - **Sorting**: know how to sort. Don't do bubble-sort. You should know the details of at least one n*log(n) sorting algorithm, preferably two (say, quicksort and merge sort). Merge sort can be highly useful in situations where quicksort is impractical, so take a look at it. - **Hashtables**: hashtables are arguably the single most important data structure known to mankind. You _absolutely have to know how they work_. Again, it's like one chapter in one data structures book, so just go read about them. You should be able to implement one using only arrays in your favorite language, in about the space of one interview. - **Trees**: you should know about trees. basic tree construction, traversal and manipulation algorithms. You should be familiar with binary trees, n-ary trees, and trie-trees at the very least. Trees are probably the best source of practice problems for your long-term warmup exercises.You should be familiar with at least one flavor of balanced binary tree, whether it's a red/black tree, a splay tree or an AVL tree. You should actually know how it's implemented. You should know about tree traversal algorithms: BFS and DFS, and know the difference between inorder, postorder and preorder. - **Graph:** There are three basic ways to represent a graph in memory (objects and pointers, matrix, and adjacency list), and you should familiarize yourself with each representation and its pros and cons. You should know the basic graph traversal algorithms: breadth-first search and depth-first search. You should know their computational complexity, their tradeoffs, and how to implement them in real code. If you understand these topics, that should act as a baseline for being prepared for an "algorithms"-based interview. ----- :::success :wave: This guide was originally authored and adapted by Nathan Esquenazi as part of the services offered to students through CodePath.org, a 501(3)c non-profit dedicated to forging an accelerated pathway into the tech industry for all university students. Special thanks to the many students, recruiters, and professional engineers that provided feedback and made this guide possible! :::