If you are sitting for the onsite interview, please check this blog on how to pass amazon onsite interview.
A few years ago, I managed to successfully pass the Amazon online coding test. It was extremely challenging. In this blog, I explain how I prepared for it.
Purpose of the Coding Test
The purpose of the online coding test is to identify candidates who may do well on the onsite interview. It basically measures how good problem solver, coder you are. Also Amazon is very serious about it’s culture. So there are some questions to judge whether you are a correct cultural fit for the company.
Exam / Test
Amazon uses an online coding testing tool. Your recruiter will send you a link to the exam. You can (and should) always follow the link and look around to get familiar with the tool. You can use most of the popular programming languages (like Java, C++, Python, Ruby…) for the test.
The test has two coding questions. Generally, first question is simpler than the second. You will have 90 mins to complete both questions. Tool provides few tests, which you can use to validate you code. You can always add extra tests to validate other aspects of your code.
Once you’ve submitted your code, you will get the opportunity to answer to Leadership Questions. There questions are MCQs. This part of the test is not timed.
Brush up your knowledge on data structures and algorithms. Cover all basics.
- Binary Search Trees
- Sorts – Merge Sort, Quick Sort, Heap Sort, Topological Sort
- Search – Binary Search
- Tree Traversals – DFS, BFS, Inorder, PreOrder and Post Order
- Prim’s Algorithm
- Dijkstra’s algorithm
- Dynamic Programming
Do not waste your time looking at too complex data structures/algorithms like the red-black trees.
Learn to Calculate Time / Memory Complexity
You are usually asked to provide the time/memory complexity of your code.So brush up how to calculate this on a code. Also try to remember time complexity of above classic algorithms.
I highly recommend you to invest on Amazon best seller Cracking the Coding Interview: 189 Programming Questions and Solutions book.
This book covers all the algorithms, data structures that needed for your interview. It also covers Time and Memory complexity calculations. It briefly goes through the interview structure of the each big company like Amazon, Google and Facebook. This book also has lot of practice questions with solutions. Book is not cheap. But a very little investment considering that it will help to get in Amazon.
Practice Practice Practice
The practice is the key. Do as much as practice questions you can. If you buy above book, you try the practice questions of the book. There are several online web sites like Leetcode which provide practice algorithmic questions. Make the best use of them.
During the Exam
You can access the internet during the exam. You are allowed to use your own IDE. But the risk is if you couldn’t copy paste your code on time, you will loose everything.
Time is Precious
50% of the exam is about time management. Problems you get are complex enough to make it difficult to finish both within 90 minutes. If the first question is an easy one, don’t spend too much time on it. Finishing both questions is far more important than brushing up the code of the first problem.
If you are running out of time, prioritize the important bits of the algorithm. For example, if you are going to implement a sort, you should prioritize the Comparator since it’s going to be to the core logic of the program.
Write Good Code
This is the first time Amazon is going to see your code. So try to give the best first impression. Follow basics; use meaningful variable/method names, move the redundant code to functions. Try to create classes instead of using complex collections. Write comments where needed. Try to output the best industrial level software you can.
Do not Brute Force
You may be tempted to solve some problems by brute force. But this will not raise any eyebrows. Try to provide a code that can do better than the Brute Force.
After coding questions, you will have to answer a questionnaire which evaluates whether you are a good cultural fit for Amazon. Try to be your self and answer honestly. If you and company are not going to be a good match, it’s going to be a bad move for both the parties.
Also, don’t trust the tool too much save your work continuously as you progress.
Personally, I took about 3 weeks to prepare my self for the coding test. So start early.