How to Pass Amazon Onsite Interview

Introduction

Before you can sit for the onsite exam, you must pass the amazon coding interview. Please check this blog on how to pass the amazon coding test.

I was able to successfully pass the Amazon exam in my second attempt. It was a very challenging and refreshing experience. In this blog, I am sharing what I did to prepare for the exam.

Interview Structure

The on-site interview has four separate interview sessions, done by four individual interviewers. Each interview should take about 55 minutes.

Out of four interviews, three will be algorithmic questions. One will be a system design question.

Algorithmic Questions

For Algorithmic questions, you will have to write your code on a paper or on a whiteboard. You can use any programming language. You will have to provide the runtime and/or memory complexity of your program. You will have about 40 minutes to finish your question. If you complete it early, the interviewer may ask you a second question.

Design Question

Same goes for the design question. You have to draw the design diagram on the paper/whiteboard and explain your question to the interviewer. Similarly, you will have about 40 minutes to complete the question.

Leadership Questions

Amazon is very serious about its leadership principles. At the end of each interview, you will be asked some questions about Amazon Leadership Principles. This will take about 10 – 15mins.

Preparation

Algorithms

Basically, follow the same set of preparations that I described here for the coding exam.

Since you won’t have IDE support during the interview, you will have to prepare for it as well. Trust me this is important. When you do practice questions do them on paper. Don’t worry about small mistakes on language syntax. But try to output the best industrial code you can.

Same principals as online coding interview applies. Use meaningful variable names, try to come up the with best code structure you can.

Design Question

Design question can be very challenging because of the ambiguous nature of it.

These questions can be of two flavors. Either it can be a very high-level question like “Design Netflix”. Or it can be quite a low-level question like “Give me a class diagram for a Table”. So either you are designing a complex system with high granular modules. Or you are designing a very simple system with very modules with low granularity.

To prepare for this exam again you have to practice a lot. Do sample amazon design questions available online. Try to glance through SOLID Design principles. Key to pass this interview is to be able to justify your design trade-offs to the interviewer. You don’t have to present your solution with AWS, or any cloud solutions for that matter. Use whatever technologies you are familiar with.

Leadership Principles

You can read about the leadership principles here. Read each one of them and try to absorb the essence of every principle. Then try to think about your past experiences where you had to apply these principles. I recommend you to prepare two examples for each of the leadership principles from past experiences.

Preparation Resources / Books

Like I have recommended in my other post, 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.

During the Interview

Think Out Loud

Always maintain good communication with the interviewer. Ask questions regularly. Also, try to think out loud. Explain your thought process to the interviewer. For a particular question if you can think of two or three solutions, explain all the solutions to the interviewer. And tell him what you think the best solution and why.

Make Assumptions

Questions can be ambiguous – sometime on purpose. Clarify ambiguities with the interviewer. You may be able to make some assumptions to simplify the problem. If you are going to make any assumptions, clearly state them.

Use Language Provided APIs

You can use any language-provided library for the algorithmic questions. This is highly encouraging because it saves your valuable time. But if you are going to use any API / Data structure, you should be able to explain the inter-workings and complexity of them to the interviewer.

Leadership Questions

For leadership questions, you will be asked about one of your past experience. And you will be asked lots of questions from different angles of the situation. It will be very hard to maintain a lie; so be honest and truthful.

One Screw up Doesn’t Count

Also, all interviewers have a vote on you. So if you screw up one interview, don’t give up. Give your best shot to remaining interviews.

Other Recommended Readings

https://www.linkedin.com/pulse/20141120061048-6976444-ace-the-coding-interview-every-time/?trk=mp-reader-card

 

//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=d1e624dd-ae12-4858-a5f9-324544f807a6

Advertisements

How to Pass Amazon Online Coding Test

Introduction

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.

Preparation

Brush up your knowledge on data structures and algorithms. Cover all basics.

Data Structures

  • Stack
  • LinkedList
  • Queue
  • Arrays
  • Heap
  • Binary Search Trees
  • Hashing
  • Graphs

Algorithms

  • 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.

Cultural Questions

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.

Finally

Personally, I took about 3 weeks to prepare my self for the coding test. So start early.

//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=d1e624dd-ae12-4858-a5f9-324544f807a6

SOLID Principles for a Good Software Design

Follow SOLID Principals

SOLID principles are widely accepted set of rules that let you design/implement reusable and flexible Classes and methods. They consist of the following five principles.

Single Responsibility Principal – Promotes Encapsulation

A class/method should have a single, well-defined functionality. They should only contain code responsible to a single actor (of a use case).

Classes and Methods change because the requirements of the actors change. If a class / a method only contain code that is responsible for a single actor, they only have only one reason to change. This is important because different actors have different requirements, which evolves in different phases and for different reasons.

Open Closed Principal – Promotes Abstraction + Polymorphism

Classes (even Systems) you develop should be open for extension and closed for modification. New functionalities should introduce new codes to a system, not changes to the existing code. The modules you design should never change. When requirement changes you should extend and add more modules to change the behavior of the system.

This principle promotes Abstraction and Polymorphism. Your module should be designed on top of immutable abstractions so it never changes. However, anyone can implement different derivations of these abstractions to introduce new behaviors to the system.

Things that change for different reasons and in different rates, should exist in different places in the code. It is impossible to make a system 100% agnostic for all changes. The designer should find the most probable changes and should make the system to be resilient against them.

Find this very interesting paper on the topic – link.

Liskov Substitution Principal – Abstraction and Hierarchy

Any subtype should be directly substituted in place of a supertype reference. This means that a reference of the supertype should be replaceable with a subtype object without breaking the program. For this principle to work, it is essential that subtype does not change the behavior of supertype. The subtype should provide all the features of the supertype, then some extra

Find the research paper here.

Interface Segregation Principle

A client should not be forced to depend on the method that it does not need. This principle enforces splitting large interfaces to several small interfaces.

Dependency Inversion Principle

Abstract modules should contain high-level business logic. Concrete implementations should contain implementation details. When a high-level module needs to call a low-level module, define an interface on the side of the high-level module to invert the dependency.

 

 

Automate Reboot and Git push with Linux Crontab

1200px-Tux.svg

Introduction

I am going to explain how you can set up daily git pushes with crontab command.

Step 1 – Disable git username/password prompt during check-in

Follow the steps on this StackOverflow post.

Step 2 – Add git commands to a sh file

Add following sh file to the repository root directory.

#!/usr/bin/expect

#Pull remote repository
git pull

#Git commit and push
git add -A

#Commit
git commit -a -m "Daily Update"
git push

Step 3 – Open Crontab

sudo crontab -e

Step 4 – Setup Daily Executions

Add following line to the crontab file. This will run the script every 8am in the morning.

0 8 * * * PATH_TO_YOUR_SH_FILE

For example, the command I used was this.

0 8 * * * /home/myhome/project/gitpush.sh

Step 5 – Setup Daily Reboot

Refer to this askUbuntu post to set this up.

 

Set up Ubuntu Mate on Raspberry PI for Python Developers

Raspi-PGB001

Introduction

This blog explains how to set up a freshly installed Ubuntu mate on a Raspberry PI for Python and Django development. If you want to know how to install Ubuntu Mate on Raspberry PI please refer to this post.

Step 1 – Enable SSH

Not really needed for this task. But handy to have it. Run the following two commands to activate it.

sudo systemctl enable ssh
sudo systemctl start ssh

Step 2 – Update Ubuntu

Run following two commands. These two will take 1-2 hours to finish.

sudo apt-get update
sudo apt-get upgrade

Step 3 – Install Importent Packages

sudo apt-get install git
sudo apt install vim

Step 4 – Install Python/Django

sudo apt install python-pip -y
pip install --upgrade pip 
sudo python -m pip install django

Install Ubuntu Mate in Raspberry PI using Mac and no Keyboard

Raspi-PGB001

Introduction

In this blog, I am going to explain how you can install your Raspberry PI using a mac and without any keyboards. Also, you need minimal technical knowledge to do so. You will need a mouse and a display device. So here it goes.

Step 1 – Download Ubuntu Mate

Get it from the following link. Then extract it to get the .img file.

https://ubuntu-mate.org/raspberry-pi/

Step 2 – Plug Micro SD card to your Mac

Connect your Micro USB card to the mac. If your mac is a new (fancy) one with only Thunderbolt ports you can buy a micro SD card adapter from Amazon for a couple of bucks.

Step 3 – Find the Device Identifier

Mac will auto-mount your micro sd card. Go to the Disk Utility, select your SD card. Note the disk identifier of your card. For my case, it is disk4. Then unmount your disk (do not Eject).

Screen Shot 2019-03-09 at 4.26.54 PM

Step 4 – Write Ubuntu Mate image to the SD card

Here is the command you should execute.

sudo dd bs=1m if=path_of_your_image.img of=identifier_of_your_disk conv=sync

For my case, here is the exact command I had to run.

sudo dd bs=1m if=~/downloads/ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img of=/dev/disk4 conv=sync

This command takes some time to complete, so stay put.

Step 5 – Boot your Raspberry

Plugin the micro sd. You need to connect a mouse and display to it as well. Turn on the raspberry and boot it up.

Step 6 – Set up username/password without a Keyboard

When it boots up it will ask you to give a login and a password. But you can’t do it because you don’t have a keyboard. The trick is to copy any text from the window and paste it on the login and password text boxes. For this example, I used “computer” username and “computercomputer” as the password. Set it up, you are good to go.

Step 7 – Enable On Screen Keyboard

Go to Applications–> Universal Access –> Onboard

Hope this helps. Refer this blog to see how you can set up Ubuntu Mate after installation for programming.