Amazon Interview Questions
- 7of 7 votes
AnswersCount number of strings of length N with following properties:
- oaashifo April 08, 2019 in India for India
A. Consists of char 'A' and 'B' only.
B. There is atleast one occurrence of 3 consecutive Bs.
Input: Only line having integer N.
Output: Number of string with given properties. As then number can be very large print it with modulo 10^9+7.
Sample Input 1:
3
Sample Input 2:
1
Explanation: Only possible string "BBB"| Report Duplicate | Flag | PURGE
Amazon Software Developer Algorithm - 0of 0 votes
AnswersIts farewell day, there are total N students, every student has bought a gift to give. He/She will give this gift to some other student. After gifting process is over, you are given an array, representing number of gift student receive i.e. ith number denoting number of gift he/she got. Your task is to find, whether given gift count array is valid or not. If it is valid print any of possible way of gifting that lead given array.
- oaashifo April 08, 2019 in India for India
PS: Student can't gift to himself. Student has exactly one gift with himself.
Input: First line will have one integer M, denoting number of students. Next line wil have N spaced integers denoting number of gift student gets.
Ouput: -1, if given gift received array is not valid else print N spaced integers denoting ith gifted to jth.
Sample Input 1:
3
1 1 1
Sample Output 1:
2 3 1| Report Duplicate | Flag | PURGE
Amazon Software Developer Algorithm - 1of 1 vote
AnswersParking lot problem: Given 3-dimensional parking lot, lets say, length width and floor. Implement following two methods: void unpark(int i, int j, int k); where i, j, k are the parking coordinates. void park(); The car should be parked in empty cell with lowest floor and between length and breadth prefer minimum length.Example, (3, 4, 2) is preferred over (1, 1, 3) as floor is 2 in first case. (1, 2, 3) is preferred over (2, 1, 3). (2, 3, 3) is preferred over (2, 4, 3).
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 System Design - 1of 1 vote
AnswersGiven an array find if array gets sorted by reversing any subarray of this array. Ex: In {1, 2, 3, 4, 8, 7, 6, 9} we can reverse subarray from index 4 to 6.
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - -1of 1 vote
AnswersLLD for third party delivery vendor for registration and notification system.
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 System Design - 0of 0 votes
AnswersDesign gaming platform. A number of games can be hosted on this platform. User can login and select a particular game.
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 System Design - 0of 0 votes
AnswersDesign Meeting calendar system. Then there was discussion on various issues on it like scalability, what database should be used; SQL-NoSQL, concurrency etc.
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 System Design - 0of 0 votes
AnswersYou are given many files of 6 GB, each having stream of integers. You have space of 4 GB left in your main memory (mainly to swap out, swap in). You have to store sorted sequence of integers in all file in a other output file. How will you do that?
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 System Design - 0of 0 votes
AnswersDesign an authentication using AWS services like Api gateway and lambda.
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 System Design - 0of 0 votes
AnswersDesign an online chess game.
- neer.1304 April 06, 2019 in United States
It supports 3 mode:
Player vs. AI
Player vs. player (Offline)
Player vs, player (Online)
The questions asked were how will you assign a player to another player who wants to play. You need to think about how to divide your players into multiple groups of ratings, so that a newbie is not playing a grand master, rather with someone who is of his level only. Then the question was how will you design your system when a player comes in and say I want to play, and the max wait time is 1 min, you need to find a player suitable for his level| Report Duplicate | Flag | PURGE
Amazon SDE-3 System Design - 0of 0 votes
AnswersDesign a movies reviews aggregator system. Data should be fetched from movie rating providers like imdb, rotten tomatoes, etc
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 System Design - 0of 0 votes
AnswersFind the sum of n elements after a kth smallest element in BST. Tree is very large, you are not allowed to traverse the tree.
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 0of 0 votes
AnswersDesign subscription based sports website which can display scores, game status, history for any games hld and lld
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 design - 0of 0 votes
AnswersConsider an infinite stream of numbers. At any point print smallest k elements.
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 0of 0 votes
AnswersGiven an array of integers(duplicates allowed) return if it is a set of contiguous integers or not?
- neer.1304 April 06, 2019 in United States
Input: 5,2,3,6,4,4,6,6 Output: Yes (as it is from set of [2,3,4,5,6])| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 1of 1 vote
AnswersGiven an array of integers with the property that arr[j] – arr[j-1] is either 1,0,-1 and a search value, provide an efficient search mechanism.
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 0of 0 votes
AnswersGiven coin denomination of 3, 6 and 17, find the number of ways in which you can form a sum 'n'. How will do it for large numbers?
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 0of 0 votes
AnswersThere is a huge road. Given are the following
- neer.1304 April 06, 2019 in United States
- Array D that stores the distance from a starting point where billboard can be installed.
- Array C that stores the profit. C[i] -> profit if the billboard is installed at distance D[i].
- dist -> minimum distance to maintain between the billboards.
Assume you can install any number of billboards while maintaining a given minimum distance 'dist' between each of them. Find the maximum profit you can achieve.| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 0of 0 votes
AnswersDesign an airport service that will be used to allocate a free runway when the plane is about to land. Data structure for the same. What if the runway is not available? Message passing between control centre and the plane. Focus on low-level design and code. Can the same runway be alloted to two different planes (locking)? Database storage needed?
- neer.1304 April 06, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-3 design - 0of 0 votes
AnswersHow to find if a Binary tree has an odd number of nodes without using node count? Binary tree does not have to be balanced
- programmer March 29, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon Backend Developer - 1of 1 vote
AnswersFind the indices of all anagrams of a given word in a another word.
- aonecoding4 February 19, 2019 in United States
For example: Find the indices of all the anagrams of AB in ABCDBACDAB (Answer: 0, 4, 8)| Report Duplicate | Flag | PURGE
Amazon Software Engineer - 0of 0 votes
AnswersWrite AWS lambda function to fetch data from on premises oracle db and migrate to aurora db.
I tried :var oracledb = require('oracledb-for-lambda'); var os = require('os'); var fs = require('fs'); 'use strict'; str_host = os.hostname() + ' localhost\n'; fs.appendFile(process.env.HOSTALIASES,str_host , function(err){ if(err) throw err; });
Can someone show me , i have table with same columns present in oracle db as well as aurora db i want to map form oracle to aurora. How to write it in java or python using aws lambda.
- Brucewratner February 04, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon Backend Developer - 0of 0 votes
AnswersDesign a data scrubber.
- kumar February 01, 2019 in India
Say a customer couldn't use Alexa with Philips light bulb. Now customer calls to Alexa/Amazon customer support they figure out the issue is not with Alexa it's with the Philips LED bulb.
Now amazon will redirect their customer call / chat to third party customer support (Philips in this case).
Now somehow we need prevent the possibility of third party customer support trying to exploit our customers. For ex: asking their bank accounts, credit card, Social Security number etc..
How will you do that for AMAZON level ?| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 0of 0 votes
AnswersYou have oracle database table , and AURORA AWS table with same fields , write a java lambda function to migrate data from oracle table to aurora. Also it should be realtime, if a new record is added to oracle it should update aurora db table as well.
- Brucewratner January 29, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon Backend Developer Java - 0of 0 votes
AnswersGiven an array of edges between any two points in 2 dimensional space. A single edge is represented by the co-ordinates of two points it is connecting for example (2,3),(4,5) represents and edge connecting points (2,3) and (4,5).Find out the total number of squares possible if all edges are parallel to X or Y axis.
- jadonv January 26, 2019 in United States
NOTE : Include overlapping squares, squares having one side in common and squares contained within another square. Co-ordinates can have float values.
Example below -
I have considered a very simple input and output combination to keep it short.
Input
{
(0,0),(0,3)
(0,0),(3,0)
(0,3),(3,3)
(3,0),(3,3)
}
Output : 1
Possible Approach : Create a map as below -
Key(Slope of Edge in Degrees) - Value(Array of Edges)
0 - {(0,0),(3,0)},{(0,3),(3,3)}
90 - {(0,0),(0,3)},{(3,0),(3,3)}
While inserting edges in the map, make sure the edges are sorted by max(x1,x2) first and then max(y1,y2).
Pick 2 edges from one slope let's say slope 0, then pick 2 edges from slope 90 and see if square is formed or not. If square not formed, then look at next 2 edges of slope 90 and so on.
Sorting here is an expensive operation.
Please share any better solutions.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersGiven a grid M x N cells having weight in each cell(any integer),
- keviIma January 15, 2019 in United States
For every path from TOP-LEFT to BOTTOM-RIGHT, find the minimum weight you come across.(Minimum per path.)
Now from all those minimum weights, find the Maximum.
You can move in all 9 directions.
Is this a trick question?| Report Duplicate | Flag | PURGE
Amazon - 2of 2 votes
AnswersGet the sum of all prime numbers up to N. primeSum(N).
- aonecoding4 January 07, 2019 in United States
Follow-up: If primeSum(N) is frequently called, how to optimize it.| Report Duplicate | Flag | PURGE
Amazon - -6of 6 votes
AnswersFind a pair that equals to the given target from the list of given two lists.
- sarunreddy82 January 07, 2019 in United States
example:
input:
target = 7
list1= [[1,2],[2,4[,[3,6]]
list2 = [[1,2]]
Output:[[2,1]]
Explanation: There are only three combinations [1,1],[2,1] and [3,1], which use a total of 4,6, 8 respectively. Since 6 is the largest use that does not exceed 7, [2,1] is the only optimal pair.
Example 2:
Input :
target = 10
list1 = [[1,3],[2,5],[3,7],[4,10]]
list2 = [[1,2],[2,3],[3,4],[4,5]]
Output;
[[2,4],[3,2]]| Report Duplicate | Flag | PURGE
Amazon Arrays - 1of 1 vote
AnswersPrroblem: write an algorithm to calculate the minimum cost to add new roads between the cities such that all the cities are accessible from each other
int numTotalAvailableCities = 6;
int numTotalAvailableRoads = 3;
int[,] roadsAvailable = { { 1, 4 }, { 4, 5 }, { 2, 3 } };
int[,] costNewRoadsToConstruct = { { 1, 2,5 }, { 1,3,10 }, {1,6,2} ,{ 5, 6, 5 } };
int numNewRoadsConstruct = 4;
- sunil.sebastian January 05, 2019 in United Statespublic class MinimumCostToConstructNewRoad { public static int getMinimumCostToConstruct(int numTotalAvailableCities, int numTotalAvailableRoads, int[,] roadsAvailable, int numNewRoadsConstruct, int[,] costNewRoadsConstruct) { int totalCost = 0; bool[] Visited = new bool[numTotalAvailableCities]; int[] Keys = new int[numTotalAvailableCities]; int[] Parent = new int[numTotalAvailableCities]; int[,] AdjMatrix = GetAdjecencyMatrix(roadsAvailable, costNewRoadsConstruct, numTotalAvailableCities); for (int i=0;i< numTotalAvailableCities;i++) { Keys[i] = Int32.MaxValue; } Keys[0] = 0; Parent[0] = -1; for(int i=0;i< numTotalAvailableCities-1;i++) { var u = FindMin(Visited, Keys); Visited[u] = true; for(int v=0;v< numTotalAvailableCities;v++) { if(Visited[v]==false && AdjMatrix[u, v]!=Int32.MaxValue && AdjMatrix[u,v]<Keys[v]) { Parent[v] = u; Keys[v] = AdjMatrix[u, v]; } } } for(int i=1;i< numTotalAvailableCities;i++) { totalCost = totalCost + AdjMatrix[Parent[i], i]; } return totalCost; } private static int FindMin(bool[] Visited, int[] Keys) { int min = Int32.MaxValue; int index = -1; for (int i = 0; i < Keys.Length; i++) { if (Visited[i] == false && Keys[i] < min) { min = Keys[i]; index = i; } } return index; } private static int[,] GetAdjecencyMatrix(int[,] roadsAvailable, int[,] costNewRoadsConstruct,int numTotalAvailableCities) { int[,] AdjMatrix = new int[numTotalAvailableCities, numTotalAvailableCities]; for (int i = 0; i < numTotalAvailableCities; i++) { for (int j = 0; j < numTotalAvailableCities; j++) { AdjMatrix[i, j] = Int32.MaxValue; } } int count = 0; for (int i = 0; i < roadsAvailable.GetLength(0); i++) { int start = roadsAvailable[i, count]-1; int end = roadsAvailable[i,count+1]-1; AdjMatrix[start, end] = 0; } for (int i = 0; i < costNewRoadsConstruct.GetLength(0); i++) { int start = costNewRoadsConstruct[i, count]-1; int end = costNewRoadsConstruct[i, count+1]-1; int cost= costNewRoadsConstruct[i, count + 2]; AdjMatrix[start, end] = cost; } return AdjMatrix; } }
| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 0of 0 votes
Answershow would you debug a tablet with a part of its touch screen is broken.
- rakshith18n December 31, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon SDET