Determine If A Binary Tree Is A Binary Search Tree
Given a Binary Tree, figure out whether its a Binary Search Tree. In a binary search tree, each nodes key value is smaller than the key value of all nodes in the right subtree, and is greater than the key values of all nodes in the left subtree. Below is an example of a binary tree that is a valid BST.
There are several ways of solving this problem. A basic algorithm would be to check on each node where the maximum value of its left sub-tree is less than the nodes data and the minimum value of its right sub-tree is greater than the nodes data. This is highly inefficient as for each node, both of its left and right sub-trees are explored.
Another approach would be to do a regular in-order traversal and in each recursive call, pass maximum and minimum bounds to check whether the current nodes value is within the given bounds.
Understand The Company’s Values
As mentioned already, Amazon has a set of leadership principles that are very important to the organization. Part of your interview will be assessing whether you exemplify these principles. So be prepared to offer examples of how you have demonstrated these principles in your past work.
For example, customer obsession is one of their leadership principles. You can talk about times you solved a problem, thinking about the end user’s experience first, and designing a solution with that experience as your primary concern. If you’re given an open-ended question, always think about it first from the customerâs standpoint, and you’ll be guaranteed to get some bonus points that way.
How I Prepared For My Interviews
After suffering through my first job search, I told myself that I must be prepared in future interviews.
I started preparing for interviews by charting out an overview of what I was good at, bad at, and where I could improve. I broke it down into three categories: data structures, algorithms, and system design.
Having worked in PHP for most of my professional career, and C++ in college, I wanted to try something a little simpler and less verbose for interviewing.
For this reason, I picked Python. It is a great language to learn, easy to pick up, supports many data structures out of the box, and can be written quickly on the whiteboard. I learned Python by going through YouTube tutorials like these, and also reading their documentation. I prefer Python 2.x, but you can go for either 2.x or 3.
Also, another reason why I picked Python is that its highly readable and easy to write on a whiteboard. Heres a trivial comparison between C++ and Python.
A C++ program to sort in descending order:
#include < bits/stdc++.h> using namespace std int main int n = size/sizeof sort) for return 0 }
Compare that with Pythons version:
a = a.sortprint a
Ive received feedback from interviewers to err on the side of brevity in an interview. In a 45-minute interview, you want to use most of your time solving the actual problem.
Pro tip: pick a language thats less verbose so that you can write the code more quickly on the whiteboard.
Read Also: How To Practice For A Job Interview
Mindset Plays A Big Role
Treat the interview as a way to discover your superpowers. These challenges are designed in such a way as to test your communication, coding, and problem-solving skills.
Do you write human-readable code, are you a team player, how do you cope under pressure, how do you approach problems. These are all the superpowers I discovered during my interview and that I have what it takes to become an Amazonian!
Now Should You Buy It

I think that EPI is one of the best resources to prepare for technical coding interviews, bar none. Regardless of your experience level, theres something in there for you. I particularly enjoy reading the book for its clear and concise explanations, and I use this book as a reference in my programming course.
If you want all the data structures, algorithms you need to know in a single, easy-to-read book, then EPI is the book for you.
For distributed systems designs, I recommend looking elsewhere. A good start is Designing Data Intensive Applications.
I love it for the depth and insights, and I recommend it to many students who are taking my courses as well.
Also Check: What To Prepare For A Phone Interview
Tips For Amazon Interview Preparation
Now that we know about the rich heritage of Amazon, its work culture, and Leadership Principles, I am sure that you are tempted to interview at Amazon and take a job! Here are a few tips which you can use to crack Amazon’s interview and get a job
System Design Scalability Data Handling
You can expect system design questions if you have 4+ years of experience.
- Scalability and System Design are very large topics with many topics and resources, sincethere is a lot to consider when designing a software/hardware system that can scale.Expect to spend quite a bit of time on this
- Considerations:
- Distill large data sets to single values
- Transform one data set to another
- Handling obscenely large amounts of data
Read Also: How To Crack Business Analyst Interview
Amazon Business Analyst Interview Questions
The general technical questions to focus on would be:
- SQL queries and ETLs
- Statistical analysis
- Product metrics
At least 1-2 rounds will be based on technical skills. For business analysts, the main skillset they are testing for is SQL, although it helps to know a little bit of Python, R, or data visualization tools like Tableau. Expect to see some easy to medium level SQL questions on Interview Query. There are also elements of data engineering such as raw data extraction, transformation, and loading data.
How To Prepare For The Amazon Aptitude Test
Here are the best ways to prepare for the Amazon aptitude test:
- Solve Amazon practice tests that are as similar as possible to the real Amazon assessment tests. Generic practice tests usually wont be enough.
- Improve the specific skills needed to ace the Amazon aptitude tests. Amazons tests will evaluate abilities and qualities that are important to working at Amazon. So, you should focus on sharpening them.
- Get used to working effectively under time pressure. Most of Amazons aptitude tests are done under tight time limits. So, you should strive to improve your performance under this type of pressure.
You May Like: How To Prepare For A Facebook Interview
The Amazon Recruitment Process
For most positions, Amazons application process looks like the following:
- Electrical Theory and Control Circuits
- Test Instruments
Heres an example of a question type youll likely see on the real Amazon maintenance test:
What is the distance at ?
The Amazon maintenance assessment is a tough test. Not only must you answer 75 questions with no breaks in between, but youll only have five days to prepare for it from the moment you receive the invitation email.
Thats why its crucial to familiarize yourself with its question types and sharpen the specific skills needed to ace the test.
In our complete Amazon maintenance test PrepPack, youll get a chance to solve realistic practice tests that simulate the actual exam.
The practice tests include in-depth explanations for every question and real time constraints. These will help improve your abilities and your performance under time pressure, resulting in a higher test score.
The Amazon Interview Process Hiring Managers And Recruiters Offer Their Best Tips
Amazons interview process can be grueling. However, the good news is that its fairly consistent. Because we know the structure of the interview beforehand, it makes it much easier to prepare and minimizes surprises. It doesnt mean the interview is easy , but it does mean that you will not be going in blind. If youre preparing for an interview with Amazon, check out our and speak to a real coach with experience hiring for Amazon.
Read Also: What Are Some Good Responses To Interview Questions
Preparation Strategy Amazon Online Coding Test
Do practise all the important topics given before and also strategy practising from Leetcode. Ideally, there is no number but you can try practising 30-40 questions from each topic and it will be enough for most of the hiring challenges.
One of the hiring challenges by Amazon on HackerEarth had two questions of medium-hard difficulty, one was based on direct application of insertion sort and other problem was a relatively hard based on graphs.
Personally, for an on-campus interview there were two coding questions, one was easy based on number of subsets and another was a direct application of Minimum spanning tree. This was also followed by an aptitude round and MCQ round consisting of code debugging questions, MCQs of CS fundamental subjects.
At the end there was a section of the cultural fit section where the type of questions was based on how to deal with conflicts and whether you are culturally fit for Amazon or not. All these sections were score based section and combining all would be used to rank the candidates for the shortlist.
Machine Learning Career Track is one destination that fulfils several prospects. This course will complement your learning experience with the blend of Machine Learning, Foundation in Python, Data Structures and Algorithms. The implication of such a trend will improve your reachability and explore different segments of technology.
What Exactly Is Amazon Looking For In Candidates

Amazon is one of the top places to work for in 2021. Its mission is becoming âthe earthâs most customer-centric company.â Letâs understand what amazon looks for in a candidate:
- Leadership recruiters at Amazon get to work with some of the best and brightest business leaders. They look for talent that uses data beyond what one would see in KPIs.
- The organization looks for people who follow Amazonâs values, including ownership and bias for action. The candidates must also think big and have a knack for inventing and simplifying.
- Amazon wants candidates who can identify problems and come up with innovative solutions.
- The company loves to see startup experience and diverse interests and backgrounds. They want candidates who have the curiosity and a self-driven desire to build something new.
- Amazon prefers candidates that show creativity and persistence, which are core leadership qualities.
- Amazon is known to hire people with a proven track record of delivering customer value.
- Amazon recruiters want candidates who can inspire a vision for their team.
- To succeed at Amazon, you should be motivated to learn new things and deliver results.
Also Check: How To Interview A Manager
Practice Questions For The Amazon Interview
Interviewing for a software engineering position at Amazon? Start with our practice programming interview questions. We’ve helped several engineers get the job at Amazon already.
“Our questions are behavioral-based and focused on assessing for fit. I encourage candidates to give examples that show how they can follow an inquiry and get to the root cause of something.”
Miriam Park, director of MBA and university recruiting at Amazon
“It’s fantastic being so close to a product where we can see how it impacts the actual customers.”
Chelsea Krueger, senior principal engineer at Amazon
Want more coding interview help?
Check out interviewcake.com for more advice, guides, and practice questions.
Actually, we don’t support password-based login. Never have. Just the OAuth methods above. Why?
Merge Two Sorted Linked Lists
Given two sorted linked lists, merge them so that the resulting linked list is also sorted. Consider two sorted linked lists and the merged list below them as an example.
def merge_sorted: #TODO: Write - Your - Code return head1
Click here to view the solution in C++, Java, JavaScript, and Ruby.
Runtime Complexity: Linear, O where m and n are lengths of both linked lists
Memory Complexity: Constant, O O
Maintain a head and a tail pointer on the merged linked list. Then choose the head of the merged linked list by comparing the first node of both linked lists. For all subsequent nodes in both lists, you choose the smaller current node and link it to the tail of the merged list, and moving the current pointer of that list one step forward.
Continue this while there are some remaining elements in both the lists. If there are still some elements in only one of the lists, you link this remaining list to the tail of the merged list. Initially, the merged linked list is NULL.
Compare the value of the first two nodes and make the node with the smaller value the head node of the merged linked list. In this example, it is 4 from head1. Since its the first and only node in the merged list, it will also be the tail.Then move head1 one step forward.
Read Also: How To Do A Group Interview
What Is The Amazon Bar Raiser
The Bar Raiser is an interviewer whose job is to examine your answers and see how they relate to the Leadership Principles. The Bar Raiser will dive deep into your answers and ask lots of follow-up questions. The purpose behind that is to shortlist the most suitable candidates that could fit Amazons unique culture.
Other Amazon Positions |
---|
The Amazon Interview Process
The basic eight-step interview process at Amazon is as follows:
Step 1. HR email or call
The first step of the Amazon interview process is when a recruiter contacts you via email, call, or LinkedIn. At this point, they’ll ask for your resume. So have one prepared.
Which resume outline should you use? Find out here.
Step 2. Online assessment
Online or take-home assessments are mostly for internship and new graduate positions. However, Amazon sometimes uses online assessments for experienced job roles as well. The organization gives three different online assessments before progressing to the phone screening stage. The different types of online assessments are:
Step 3. Phone screening
This lasts about 45 minutes to 1 hour. A typical phone screening round is where the recruiter will assess your interest and fit for the role. They will also ask fundamental questions about your background and work experience.
Step 4. Video interviews
Step 5. Final âLoopâ Interview
The bar raiser will focus on:
Step 6. Hiring meeting
Step 7. Reference check
Step 8. Offer rollout
Recommended Reading: What Are Questions That Are Asked In Interviews
Preparing For An Amazon Coding Interview
The Amazon Coding Interview is part of the overall Amazon interview process. In general, there are three types of interviews you will attend, coding interviews, system design interviews, and behavioral interviews. You may find these three intermixed during the interviews. However, all of them are important for getting a job within one of the Amazon teams.
Amazon will ask you to come onsite if you get through the online coding interview. Amazon splits onsite interviews into around six of various kinds. So, for example, it could include four coding interviews, which are four opportunities to show your code to four different Amazon developers.
Amazon Leadership Principles Interview Questions
For Amazon’s leadership behavioral competency interview, the exact phrasing of the question may be different but the central idea remains the same between each leadership principle.
For each leadership principle, remember to craft a story around how you exemplified each one of these principles. For example:
- Customer Obsession: Took customer feedback and learned from their pain points to build a better product or process.
- Dive Deep: Solved a complex problem by diving into the issue head first.
- Bias for Action: Prioritized action and initiative for different projects.
- Ownership: A project where you went beyond the original scope.
- Earn Trust: Resolving a conflict between different team members and built a good standing relationship with customers.
- Invent and Simplify: A project where you made a system more efficient.
The interviewer will never state that they’re asking you a leadership principles type question. Yet know exactly how to craft a story that leads to one of the fourteen principles. It’s basically the elephant in the room!
Scenario Based Questions
For these scenario-type questions such as tell me about a time where you…etc, it’s helpful to think about the STAR method. The STAR method is a simple framework to elaborate on your work experience.
Situation: Setting the scene and give context.Task: Describe what your responsibility was.Action: Explain exactly what steps you took to address it.Result: Share what outcomes your actions directly achieved.
Recommended Reading: How To Prepare For Machine Learning Engineer Interview