0% found this document useful (0 votes)
28 views

Amazon Coding Questions

Uploaded by

gamingblastoraid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Amazon Coding Questions

Uploaded by

gamingblastoraid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

TOP 30

CODING QUESTIONS
in
Question 1

Easy
Add Binary
Given two binary strings a and b return their sum as a
binary string. s

Practice Question Asked in:

Question 2

Easy
Diameter of Binary Tree
Given the root of a binary tree, return the length of the
diameter of the tree.
The diameter of a binary tree is the length of the longest
path between

any two nodes in a tree. This path may or may not pass
through the root

Practice Question Asked in:

Curated by
Question 3

Easy
Valid Anagram

Given two strings s and t , return true if t is an anagram of

s , and false otherwise.

An Anagram is a word or phrase formed by rearranging

the letters of a

different word or phrase, typically using all the original

letters exactly once.

Practice Question Asked in:

From To

Success

Akansha Likhdari
Story

Curated by
Question 4

Easy
Binary Search
Given an array of integers nums which is sorted in
ascending order, and an integer target , write a function
to search target in nums . If target exists, then return its
index. Otherwise, return -1 .
You must write an algorithm with 0(log n) runtime
complexity.

Practice Question Asked in:

Question 5

Easy
Longest Palindrome
Given a string s which consists of lowercase or uppercase
letters, return the length of the longest palindrome that
can be built with those letters.

Letters are case sensitive, for example, "Aa" is not


considered a palindrome here.

Practice Question Asked in:

Curated by
Question 6

Easy
Lowest Common Ancestor of a Binary

Search Tree

Given a binary search tree (BST), find the lowest common

ancestor (LCA) node of two given nodes in the BST.

According to the definition of LCA on Wikipedia: “The

lowest common ancestor is defined between two nodes p

and q as the lowest node in T that has both p and q as

descendants (where we allow a node to be a descendant

of itself).”

Practice Question Asked in:

Courses Offered by Tutort Academy

Data Structures Full Stack

and Algorithms
 Specialisation


with System In Software

Design Development

Learn more Learn more

Curated by
Question 7

Easy
Flood Fill

An image is represented by an m x n integer grid image

where image[i][j] represents the pixel value of the

image.

You are also given three integers sr , sc and color . You

should perform a flood fill on the image starting from the

pixel image[sr][sc] .

Return the modified image after performing the flood fill.

Practice Question Asked in:

Why Tutort Academy?

Career Hiring
Highest

1250+ Transitions 350+ Partners 2.1CR CTC

I really want to thank Tutort Academy from bottom of my heart for

helping me brushing up system design, data structures and algorithms

for the Google interview preparation.


Ashish Joshi

Curated by
Question 8

Easy
Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.

Practice Question Asked in:

Question 9

Easy
Linked List Cycle

Given head , the head of a linked list, determine if the

linked list has a cycle in it.

There is a cycle in a linked list if there is some node in the

list that can be reached again by continuously following

the next pointer . Internally, pos is used to denote the

index of the node that tail's next pointer is connected

to. Note that pos is not passed as a parameter.

Return true if there is a cycle in the linked list. Otherwise,

return false .

Practice Question Asked in:

Curated by
Question 10

Easy
First Bad Version

Suppose you have n versions [1, 2, ..., n] and you want to

find out the first bad one, which causes all the following

ones to be bad.

You are given an API bool isBadVersion(version) which

returns whether version is bad. Implement a function to

find the first bad version.

Practice Question Asked in:

Tutort Benefits

1:1 Mentorship from


Dedicated Placement

Industry experts Team

Curated by
Quetsion 11

Medium
Permutations

Given an array nums of distinct integers, return all the

possible permutations. You can return the answer in any

order.

Practice Question Asked in:

Question 12

Medium
Merge Intervals

Given an array of intervals where intervals[i] = [starti,

endi] merge all overlapping intervals, and return an array

of the non-overlapping intervals that cover all the

intervals in the input.

Practice Question Asked in:

Curated by
Question 13

Container With Most Water Medium

You are given an integer array height of length n . There


are n vertical lines drawn such that the two endpoints of
the ith line are (i, 0) and (i, height[i])

Return the maximum amount of water a container can


store.

Practice Question Asked in:

Question 14

Kth Smallest Element in a BST Medium

Given the root of a binary search tree, and an integer k ,


return the kth smallest value (1-indexed) of all the values
of the nodes in the tree.

Practice Question Asked in:

Curated by
Question 15

K Closest Points to Origin Medium

Given an array of points , where points[i] = [xi, yi]

represents a point on the X-Y plane and an integer k ,


return the k closest points to the origin (0, 0)
You may return the answer in any order.

Practice Question Asked in:

Question 16

Longest Substring Without Repeating


Medium

Characters
Given a string s find the length of the longest substring
without repeating characters.

Practice Question Asked in:

Curated by
Question 17

3Sum Medium

Given an integer array nums, return all the triplets

[nums[i], nums[j], nums[k]] such that i != j , i != k and j !


= k , and nums[i] + nums[j] + nums[k] == 0
Notice that the solution set must not contain duplicate
triplets.

Practice Question Asked in:

From To
Success
Gautam Verma Story

Curated by
Question 18

Binary Tree Level Order Traversal Medium

Given the root of a binary tree, return the level order


traversal of its nodes' values. (i.e., from left to right, level
by level).

Practice Question Asked in:

Courses Offered by Tutort

Data Structures and Full Stack Specialisation



Algorithms
 In Software Development
with System Design

Learn more Learn more

Data Analytics and
 Data Science and



Business Analytics Artificial Intelligence
Program Program

Learn more Learn more

Curated by
Question 19

Medium
String to Integer (atoi)

Implement the myAtoi(string s) function, which converts

a string string to a 32-bit signed integer (similar to C/C+

+'s atoi function).

Return the integer as the final result.

Practice Question Asked in:

Question 20

Medium
Spiral Matrix

Given an m x n matrix return all elements of the matrix in

spiral order.

Practice Question Asked in:

Curated by
Question 21

Course Schedule Medium

There are a total of numCourses courses you have to


take, labeled from

0 to numCourses - 1 . You are given an array


prerequisites where prerequisites[i] = [ai, bi] indicates
that you must take course bi first if you want to take
course ai .
Return true if you can finish all courses. Otherwise, return
false .

Practice Question Asked in:

From To
Success
Akash Shrivastava Story

Curated by
Question 22

Implement Trie (Prefix Tree) Medium

Implement the Trie class:

Trie() Initializes the trie object.

void insert(String word) Inserts the string word into the


trie.

boolean search(String word) Returns true if the string


word is in the trie

boolean startsWith(String prefix) Returns true if there is


a previously inserted string word that has the prefix.

Practice Question Asked in:

Thank you so much to Tutort and Team for helping me crack multiple
offers. Although currently US job market is at its worst. Credit goes to
you and Team especially Sunny Mongia and my mentor Rohit Verma.
Nayana Jabisetti

Curated by
Question 23

Medium
Clone Graph

Given a reference of a node in a connected undirected

graph. ,

Return a deep copy (clone) of the graph.

Practice Question Asked in:

Question 24

Medium
Evaluate Reverse Polish Notation

You are given an array of strings tokens that represents

an arithmetic expression in a Reverse Polish Notation.

Evaluate the expression. Return an integer that represents

the value of the expression.

Practice Question Asked in:

Curated by
Question 25

Find Median from Data Stream Hard

The median is the middle value in an ordered integer list.


If the size of the list is even, there is no middle value, and
the median is the mean of the two middle values.
For example, for arr = [2,3,4] , the median is 3

For example, for arr = [2,3] , the median is (2 + 3) / 2 = 2.5

Practice Question Asked in:

Question 26

Word Ladder Hard

A transformation sequence from word beginWord to word


endWord using a dictionary wordList is a sequence of
words beginWord -> s1 -> s2 -> ... -> sk such that:
Given two words, beginWord and endWord , and a
dictionary wordList , return the number of words in the
shortest transformation sequence from beginWord to
endWord , or 0 if no such sequence exists.

Practice Question Asked in:

Curated by
Question 27

Hard
Basic Calculator

Given a string s representing a valid expression,

implement a basic calculator to evaluate it, and return

the result of the evaluation.

Practice Question Asked in:

Question 28

Hard
Maximum Profit in Job Scheduling

We have n where every job is scheduled to be done from

startTime[i] to endTime[i] , obtaining a profit of profit[i]

Return the maximum profit you can take such that there

are no two jobs in the subset with overlapping time range.

Practice Question Asked in:

Curated by
Question 29

Hard
Merge k Sorted Lists

You are given an array of k linked-lists lists , each linked-

list is sorted in ascending order.

Merge all the linked-lists into one sorted linked-list and

return it.

Practice Question Asked in:

Question 30

Hard
Largest Rectangle in Histogram

Given an array of integers heights representing the

histogram's bar height where the width of each bar is 1 ,

return the area of the largest rectangle in the histogram.

Practice Question Asked in:

Curated by
Start Your
Upskilling with us
Explore our courses

Data Structures and Full Stack Specialisation



Algorithms
 In Software
with System Design Development

www.tutort.net

Watch us on Youtube Read more on Quora

Follow us on

You might also like