This work is a mix of fiction and non-fiction for entertainment and inspiration purposes.
My name is E. I have been working as software engineer for 18 years. I change jobs every 2-4 years. It is not I like to have challenges or seek higher pay. It is just how this field runs. When the companies have money, they hire people. If the companies run out of money, they lay off people. Alas, the layoff is unavoidable and frequent. I wish I knew this when I went to college for computer science major.
I was never a tech geek. I even didn’t touch computer before I went to college. I was pushed to study computer by my practical parents. They thought this major could guarantee stable income.
It is partially true. There is benefit to work as engineer. The work has trained me how to build things. I’m the fixer in my house. I am capable of finding solutions and solving problems . “E can deliver” is a quote from my performance review. But changing job every 2-4 years is daunting.
The current company has been developing the internet devices. They want to hold a spot in crowded IOT. The developers receive the email on how many customers signed up daily. We are growing. But the rumor says the executives couldn’t find more funding . My manger hasn’t hold team meeting for a while. We work on bug-fixing. The layoff is in the air. I have updated my resume and sent to dozen of companies. Amazon is one of them.
Since there is not much work around, I use the time to collect the interview questions and practice. I read online stories and get the idea that it is tough to pass the coding interview. Some questions seem really challenge. For example, I studied tree data structure in college, but never used in any of the job. I would fail if I run into tree questions. In the work, finding the right tool to solve the problem is more important. And I am good at using library or APIs provided by languages.
But if I want to get the job, I have to compete with those new graduates. They are equipped with latest updates in data structures and algorithms. I have no advantages whatsoever.
2. Amazon interview prep
Weeks later, I received an email from Amazon. Sarah was a recruiter from customer payment department. She said she would like to schedule the interview with me. First I had to pass the online assessment. There would be two coding questions. I had one week to finish. I accepted.
In this week, I focused on the basic data structures, such as arrays, stings, linked list, trees, and their operations. While I was practicing data structures, I also refreshed knowledge in algorithms, binary search, sorting, and greedy.
On Friday afternoon, I clicked the online assessment link. They provided an exercise to warm up before the test. It was an array problem. I solved the question quickly. This boosted my confidence. I moved on to the real questions.
I had 45 minutes to solve one problem. The question statement was long. It intended to disturb us. After I finished reading, I figured it asked to sort the strings mixed with digits and letters. I could write a comparator to sort them. I wrote the code, tested, and moved on to the next one.
The second question was the schedule of flights. Given the list of flights with their mileages, optimize the sequence so that the overall travel distance from A to B is minimum. This could be done using the HashMap and PriorityQueue. I finished coding and submitted. I felt lucky these questions were not as crazy as those on coding practice sites.
Couple of days later, I received the email from Sarah saying that I passed the online assessment. Amazon would fly me to Seattle for on-site interview. She also emailed me the preparation materials. One of them was “leadership principles”. I had to prepare a few projects to demonstrate I mastered these principles.
I was not too worried about the leadership or behavioral questions. After years’ working experience from jobs to job, I could find the stories to fit in those principles. Sarah also mentioned I should prepare for the system design. By looking at some examples of the system design questions. I felt I should be able to handle them since I had worked on the scalability of the systems.
The real challenge was the coding questions. I had to learn a lot to fill the gap, such as graphs, adjacent matrices, and tries. I also had to pick up the algorithms that I’m not familiar with, depth first search, Breath first search, Dynamic programming, and Dijkstra etc.
I took a week off to prepare for the interview since there was no substantial work in the office. On Thursday, I received the phone call from my manager. Our company laid off around 60 people that day. That’s more than half of the employees. I’m one of them. I felt relieved. Now I could concentrate on the preparation one hundred percent.
For the next couple of weeks, I continued practicing the coding questions. I learned a lot about how to optimize by applying data structures or algorithms efficiently. I was also stressed out that I would have to solve any coding question within 30 minutes. Being fast was the key. I asked myself, “be honest to yourself, are you ready or not?” The answer is no.
3. The trip
The interview was scheduled on Monday. I took airplane on Sunday afternoon. The hotel was located inside the Amazon Seattle campus. The interview building was a couple of blocks away. When I arrived at the hotel, it was still bright outside. So I decided to look around and might find a place to have dinner. There were no people on the street. And there were not many restaurants open. Finally I saw CVS was open. I bought instant noodles for dinner.
At night, I took a last look at the flash cards I prepared for review. I walked through the code in my head. It was hard for me to fall asleep. Next morning I opened my eyes and looked outside the window. The floor was wet. It must have rained last night. I had breakfast downstairs. When I came back to the room, I changed to a business casual suit. Looking at the mirror, I repeated a few times “I got this!”- a trick I learned from “brain games” positive thinking.
As planed, I left room 20 minutes early. The street was full of people, cars and buses. I walked inside the building, straight to the front desk and checked in. After signing a few paper, I got my badge and sat in the waiting area.
There were a few guys sitting in the area. They might be interviewees as well. They all looked in their 20s. I felt a little ashamed that I might be too old for this game. Then I said, “What can I lose?” I reviewed the schedule for today. The first interviewer was the hiring manager. His name was George.
4. Amazon interview On-site
Round 1 – Couple minutes before 8 am, a young man walked to me. He looked in his 30s. He must be George. We shook hands. He led me to upstairs and found the meeting room booked earlier.
He started with a couple of “leadership principle” questions. One question was whether I have led a project. I talked about how I led the project to scale the servers in the cloud. He typed while I was speaking. Then here came the system design question – a payment system.
Darn it! I knew little about payment. It caught me off the guard. All I knew was from my personal financial experience. From top of my head, I grabbed any knowledge that related to payment. The system should have billing, invoice, credit card info etc. George asked me to draw the components on the board and designed APIs. I drew circles to represent components and drew some lines between them. Meanwhile I wrote the APIs next to them. The writing overlapped each other. It was a mess.
George could tell I was struggling. Time was up. He took the pictures on the board, greeted politely and left the room.
Round 2 – The second interviewer was a lady. She introduced herself she was a manager. She and George both worked in the payment department, but in different teams. She started with the leadership questions – “Tell a case that your decision helps customers”. I gave the case how I found the open source tools to save the team from paying 50 thousands of license fee.
Next she asked coding question. she presented the question as a use case. After she finished the statement, I figured this problem could be modeled as a tree and could be solve by finding the “max path sum” of the tree. She agreed and let me code on the board.
As I know, many problem in tree can be solved by recursion. Usually there are a wrapper method and helper method. What wrapper does is to define and initialize the variables and call helper. The helper method normally has root node as input parameter. Inside the method, it calls itself with the child nodes. Here I added a class level global variable to keep track the value of “maxSum” as return. This value was updated by helper.
She seemed to have doubts about the code. She questioned me what the problem would be if there were many threads. I didn’t quite follow. We spent minutes discuss the use cases. Gradually I got the clue. To avoid the problem, I shouldn’t use the global variable. The work around was to define the variable in the wrapper method as an array, then pass the variable as input for the helper. This data could be returned from array when it was called. After I changed the code on the board, she nodded her head. I won her over!
Round 3 – While I was catching my breath, here walked in a young guy. He might just graduated from the college and looked energetic. He started the coding session right away. It was string concatenation problem. Given an array of strings, find the strings that concatenated from other words in the array. From recent study, it seemed DFS was the way to solve this kind of problem. For each word in the array, loop through all the possible substrings and compare with other words. Then using the substring as parameter, the DFS method calls itself to check further.
I also learned a new technique “memoization” during prep – Use a variable to store the result from the previous steps. If the input data has been stored, the result can be retrieved directly. This optimizes the recursion solution the and has better performance
After I coded on the board, the young guy said that I was at the right path. He asked me to run the test with the code on the board. I used the sample data to run the test case verbally. I fixed some problems here and there. The method returned the expected result. He accepted the answer. I was so happy and reminded him to take picture of the board. I could win some points from this round!
Round 4 – This was the last round, I soldiered on. Two engineers came in. The senior one was a man. The other one is a young girl. She was the shadow of the interview. The senior engineer asked a leadership question, how to help other coworkers in the project. I found example from my experience. He quickly moved on to the coding questions – implement a data structure stack with min method. The class should have push and pop methods. It also has min method to return the minimum value of the stack.
I saw this question before. My understanding was to have a variable to keep track the minimum value in the class. Also compare and update its value when push or pop data. He asked me to illustrate the data flow on the board. So I did. he agreed with the approach and asked me to write the code.
I started with the definition of the class and variables. When he saw I called Stack API to create an assistant stack, he stopped me. I am not allowed to use any library, and I had to implement with generic data type. There were only 15 minutes left. I was a little panic. Immediately I reminded myself “you can do this!”. The layout of linked list implementation became clear in my mind. I wrote the code quickly – define the node with next pointer, declare head node in class… Everything came together. I finished push and pop methods by adding and removing notes from linked list.
After I finished the coding, He accepted the solution, and asked whether I had question for him. I asked how is the work in Amazon? He gave me a standard answer – “ rewarding” . It is 12pm, they walked me downstairs to the front desk. We shook hands and said goodbye.
I finished! I felt I could breath now. What a journey! Three coding interview went well. My preparation paid off. But I was not sure about the system design. George was the manager. He could vote me out. I was 75% confident.
In the next week, I nervously waited for the call or email from Sarah, not email or phone call. I waited for another week, still not phone or email. My hope dropped to less than 50%. At the end of third week. I sent email to Sarah for result. Another couple of days later, she replied “no offer”. The reason was “I was not a good fit for the team”. She didn’t’ give more details.
I figure the “not fit” means
- I have no idea about the “payment system”.
- I’m not one of them (The average age of employees is around 30!).
Java coding interview youtube series
The complete list of coding interview questions