Cracking the Coding Interview
Rustam-Z π β’ 8 June 2021
Overall, it took me 1.5 years to crack the MAANG interview, including learning algorithms and data structures, practicing coding & problem-solving, and applying and passing all interviews. During this period I had interviews at Meta, and a successful interview at Bloomberg.
Join my Telegram channel: @cracking_maang, where I share MAANG interview preparation resources.
My Interview Preparation Roadmap
- Learning algorithms and data structures.
- Solving algorithms, and learning patterns and concepts.
- Practicing coding & problem-solving questions together with friends on the whiteboard.
- Learning System Design (I will write a separate article about System Design).
- Writing a resume.
- Applying to jobs.
- Preparing for a behavioral interview.
- Getting an interview invitation, passing all interviews, and getting an offer! πΎ
Learning Algorithms and Data Structures
- I had a Data Structures class at university. Here are the notes from the class.
- Naso Academy DS playlist
- Jenny's DSA playlist
- Programiz.com/dsa
- Data Structures by a Google Software Engineer
- NeetCode videos: hereβs one of them
- AlgoExpert Data Structures course
- Extra:
System Design Learning Plan
- "Systems Expert" from AlgoExpert
- "System Design Interview" book - 1st and 2nd editions
- "Grokking the System Design Interview" (educative.io)
- "Designing Data-Intensive Applications" book
- Tushar
Data Structure Topics to Learn
- Big-O = how quickly the runtime grows relative to the input as the input gets arbitrarily large.
- Strings
- ASCII, Unicode
- How are strings implemented in your programming language (for example, is there a maximum length)?
- Search for substrings (for example, the Rabin-Karp algorithm).
- RegEx
- Arrays. Details of implementation in your programming language. For example, for C++ you need to know the implementation using pointers, and vectors. For vectors, you also need to know, for example, that it periodically does resize, and other similar details.
- Sorting algorithms. Especially make sure you know heap sort, merge sort and quick sort.
- Searching algorithms. Binary search.
- Linked lists
- Singly linked list
- Doubly linked list
- Algorithm: Fast and slow pointer
- Algorithm: Pointers with next
- Algorithm: Searching in linked lists
- Stacks and Queues
- Trees
- DFS (must learn)
- BFS (must know)
- Preorder (must know)
- Postorder
- Inorder
- Recursive and iterative problem solving
- Adding and removing elements
- Less common tree types (e.g., red black trees, B-trees) - what are they, how they differ from the binary trees, basic complexities, and how they are used. No need to know all the rotations in the RB-tree, for example.
- Tries
- Heaps
- Heap sort
- Using heaps for tracking top-K
- Allocating elements on a heap vs on a stack - what does it mean?
- Graphs
- DFS, BFS
- Topological search
- Shortest path
- Hash
- Hash functions
- Universal hash
- Algorithmic Paradigms
- Brute Force
- Greedy Algorithms
- Divide and Conquer
- Dynamic programming
- Dynamic programming = problems, which are problems where the solution is composed of solutions to the same problem with smaller inputs.
- Recursion
- Memoisation
- Backtracking = Backtracking is an algorithmic technique for solving problems recursively by trying to build a solution incrementally, one piece at a time.
- Button up
- Top down
Practicing Coding & Problem Solving
- Interviewbit.com
- LeetCode Explore (only data structures cards)
- LeetCode Study Plan β Data Structure 1, Algorithm 1, Programming Skills 1
- "Cracking the Coding Interview" + CTCI problems in LeetCode
- LeetCode Study Plan β Data Structure 2, Algorithm 2, Programming Skills 2
- AlgoExpert video solutions
- Neetcode.io & NeetCode playlist
- Start with https://neetcode.io/practice?tab=neetcode250 250 if you have 0 knowledge in DS & A, otherwise start with TOP 150.
- LeetCode company-tagged questions, check LeetCode discussions, check Team Blind, check Glassdoor for recently asked questions.
Top Coding Interview Concepts
List of patterns to solve algorithms:
https://hackernoon.com/14-patterns-to-ace-any-coding-interview-question-c5bb3357f6ed
Top coding interview concepts:
- Heap top=O(1), insert=O(log n), remove=O(log n), heapify=O(n)
- Sliding window, two pointers
- Binary search O(log n)
- DFS & BFS
- Recursion (trees, graphs, backtracking, DP and more)
- HashMaps search=O(1), insert=O(1), remove=O(1)
Problem-Solving Approach
Constraints, Ideas, Complexities, Code, and Tests
- Read the problem. Donβt immediately jump into coding!
- Understand inputs and outputs. Draw some examples on paper.
- Clarify requirements, ask questions (I am providing the list of questions below), and find constraints (edge cases). Example questions: Is it ASCII or Unicode? What is the max value? Is there a difference between capital letters and small letters?
- Think about the solution in your mind. Divide problems into sub-problems. Come up with different ideas (ask whys, think about trade-offs, solve simpler versions, imagine helper functions - go from high level to low level).
- Evaluate the complexity and trade-offs.
- Think of a better alternative solution.
- Write code on paper.
- Debug your code on paper and test with new corner case inputs.
- Write code. Write clean code.
- Write tests. Positive, negative, with edge-cases.
More to read:
Questions: Corner Cases and Constraints
Ask about edge cases (propose edge case). Explain and clarify, DS tradeoff, time and space complexity.
Questions
How am I receiving this data?
How should I output the result?
What if wrong input is provided?
How long/big our input could be?
Empty inputs, null values, 0 length, 1 element input, super long input.
Is size, speed, using not build-in library a concern?
How I would be testing? Tests: Zero, one, two, two to max-1, max, max+1
Questions to ask
Extra: Taking the Edge Off of Edge Cases
General Tips
Interviews are not only about evaluating your technical knowledge. Explain your thought process and show how you approach problem-solving in a structured way step by step.
Many questions asked by interviewers are open-ended, so ask good questions to clarify a full set of criteria to solve the problem and clarify requirements.
Always, always, always ask clarifying questions before jumping to a solution.
Try thinking of different solutions to a given problem and explain why you came up with this solution or this code. Compare your solutions, compare complexities, and think about their trade-offs.
Overall, the interview should be like a dialogue β show how it is to work with you, how collaborative you are.