## Amazon Interview Questions

- 0of 0 votes
We define an undirected graph g,such that: The total number of nodes in the graph is g_nodes. The nodes are numbered sequentially as 1,2,3….g_nodes. The total number og edges in the graph is g_edges. Each edge connect two distinct nodes(i.e no edge connect a node to itself). The weight of the edge connecting nodes g_to[i] and g_from[i] is g_weight[i]. We define the weight of the path from some start node to some end node to the sum of all edges traversed on the path. Input formate: The first line contain two space-seperated integer describing the respective value of g_node and g_edge. Each line I of the g_edge subsequent lines contain three space –seperated integer describing the respective value of g_to[i],g_from[i] and g_weight[i]. The next line contain an integer denoting start The next line contain an integer denoting end. The next line contain an integer denoting w_extra. input 1:

4 4

1 2 2

2 3 1

2 4 2

3 4 3

1

4

5

Output:4

input2:

5 5

1 2 2

1 4 4

2 3 1

3 4 3

4 5 1

1

4

2

output:3

Int mincost(int g_nodes,int g_edged,int* g_from,int* g_to,int* weight,int start,int end,int w_extra)

{

}

- 0of 2 votes
write a SQL query to retrieve the number of students that received a GPA of 3 or 4. the query should return Total number of students that receive a GPA of 3 separate from Total number of students that receive GPA 4.

Schema:-

Student:- Student_ID, name, phoneno, email, gpa, gradyear

Classes: Class_ID, name, description

student_classes:- Class_ID, Student_ID, Grade

- 0of 0 votes
Design a service to generate unique 64 bit IDs

- 0of 0 votes
When I payment by debit card then this shown in box for that gift card, Pramotional card number reply me what is this please guide me

- 0of 0 votes
Given a set of numbers, find out all subsets of the set such that

the sum of all the numbers in the subset is equal to a target number.`s = [ 1, 2, 3, 4, 5 ] target = 5 op = [ [ 1,4 ] , [2,3] , [5] ]`

Application: Given a fixed budget, and work items we are doing back filling to check what all we can attain with the budget.

Continuation. Imagine the set is actually a set of work items, with cost and utility involved :`def work_item : { name : 'foo bar' , cost : 10 , utility : 14 }`

Now, solve this to maximise utility.

Continuation. Imagine that the work items are related, so that, if work item w1 is already in the

subset of the work items selected, w2 's utility increases further!.

( Can you imagine how it can happen? Effectiveness of Mesi increases when he plays for Barca)

So, you are given a list like this :`w1 -> normal utility 14, with w2 20, ....`

Now maximize payoff.

NOTE: Payoff is a matrix. This comes from game theory.

Hence, a payoff matrix looks like :`w1 w2 w3 w4 .... w1 w1 w2 w2 w3 w3 w4 w4`

A cell ( i,j) is filled up with if a list contains both wi and wj, then how much the payoff would be. It is a symmetric matrix.

- 1of 1 vote
Given that an external service gives a list of credit cards that have become fraud, design a fraud management system for a shopping website for bookings with fraud credit cards

- 0of 0 votes
Given a list of shops each of which have a list of toys with their prices and max number of children who can play with it at a time. Output the a list of best possible toy option from each shop given the number of children who are shopping.

ToyShopping

{

getListOfBestToysFromEachShop(List<Shop> shops);

}

Shop

{

int id,

List<Toy> listOfToys;

}

Toy

{

int toyId;

int shopId;

int price;

int maxChildren; //max number of children who can play with this toy

}

- 0of 0 votes
Function to print shortestpathsum between start and end node of given weighted undirected graph

Comlite the function:

ShortestPathSum(graph g,start,end)

Node(1)----wieght--->node(2)

Node(2)--weight-->node(3)

Node(2)----W----node(4)

Node(3)-----w----->node(5)

Node(4)---w--->node(5)

suppose node(1) is stat node and node(5) is end node

Please write the complite function

- 0of 0 votes
CAREERCUP is a boad game hat contains m x n on a board. The objective of the CAREERCUP game is to reach the bottom of he board (bottom right corner) from the top of the board (top left corner) while moving one grid at a ime in either the down, right or diagonally downwrd directions.

Write a method called CareerSolution that takes in two integers representing m and n, and returns the total number of ways a player can complete the game.

PS: Was later asked to optimize the solution.

int CareerSolution(int m, int n) {

}

- 0of 0 votes
Function to print shortestpathsum between start and end node of given weighted undirected graph

Comlite the function:

ShortestPathSum(graph g,start,end)

- 1of 1 vote
Program to print string value if each vowel of associated with value 1 and each consonant associated with value 2 print the sum of string value

Ex if input:a

Print O/p:1

I/p:ab

O/p:1+2=3

I/p:abcd

O/l:1+2+2+2=7

I/p:abcde

O/p1+2+2+2+1=8

- 1of 1 vote
Given an array of 1 billion numbers with just a few 100 missing, find all the missing numbers. you have only enough memory to store only 10k elements

- 0of 0 votes
Design the classes for a Battleship Game. Write the attack function.

- 0of 0 votes
Write a program to check whether it is a valid binary tree or not. Check all test cases (e.g. No left Node case).

- 0of 0 votes
Consider that your office provides an app to book meeting rooms. You provide the start and end time of the meeting. The app list the available rooms for that slot and you select a room and confirm your booking.

All meeting happen between 9am - 6pm.

Write a method for getAvailableRooms(startTime, endTime). Use appropriate data structures.

- 1of 1 vote
count the duplicates in a array of strings??

- 0of 0 votes
Write test cases for refrigerator?

- 2of 4 votes
A frequent traveller collects all his travel tickets.

A ticket has only 2 attributes, Start Journey Location name and Destination Name. Example from Delhi to Mumbai.

At the end of the year, the traveller gets all his tickets together and tries to map his journey across the year. Print his travel route in a readable format. He does not remember his start location.

Edit: he can visit a location multiple times, and can also go back and forth a place several times.

- 0of 0 votes
Suppose there is a social networking site like Facebook. Every user gets some friend recommendations (i.e. People you may know!). Now, if there is a user A and he has 100 friends and each of his friends has got 5 other friends,A can get these 500 recommendations. But the condition is that he should only get the top 10 recommendations with whom he has the maximum number of mutual friends(If A and B are friends and B and C are friends, then A and C have a mutual friend, B). Suggest an efficient data structure for this and how to implement it. The implementation should be flexible as at any moment, any user can make new friends and he may also unfriend someone!

- 0of 0 votes
User uploaded file in File container/storage --> Its parsed by 1 App and removed frim storage --> App having logs --> App stored data into database

--> One User interface featching data from DB havinig fields Username, Report ID, ProductID --> This UserInterface also connected to Report Application.

ProductID came from file, ReportID generated in report.

User interface not showing any data so what could be the issue?

- 0of 0 votes
Program- Metrics- Find Kth position in metrics in N X N metrics in spiral form

- 0of 0 votes
"aabcbcbdcc" you can remove and shuffle characters, find the maximum length of string which forms palindrome.

like "ccabdbacc"

- 0of 0 votes
5. Search functionality not working in Amazon shopping application in smartphone but its working through website, how you will debug this?

- 0of 0 votes
4. Generate Test data for below function Grade(Obtained marks, Total marks) having below grading system.

0% to 40%= D grade

41% to 60%= C grade

61% to 80%= B grade

81% to 100%= A grade

Grading calculation=Grade(20,40)=100*(20/40)= C grade

- 0of 0 votes
3. Write a program to display numbers having sum of left side numbers equal to right side numbers.

{1,0,-11,1,12}=>0 {Left side number 1+0=1, Right side number -11+1+12=1}

- 0of 0 votes
2. Write a program to diplay a character occurred maximum times and if two charaters occurring same no of times then display 1st character in string.

"HELLO WORLD!" display L

"HO HELLO!" display H (H, L and O appeared 2 times but H is in 1st in string)

- 0of 0 votes
1. "Unified search" for Email App, Web content and for SDCARD/Internal memory, which search word, letter and display result.

Its a smartphone app. Write the test case for this.

- 0of 0 votes
Design a logging system. The system contains multiple application servers which are logging the information to file system. In this scenario, we want to check and alarm in case an exception is thrown in any of the servers. We want a system that checks for appearance of specific words, "Error", "Exception", "Disk Full" etc. in the logs of any of the servers. How would you design this system?

What if we want to scale the system in future?

- 0of 0 votes
Write a Junit test for the following 2 methods in the class which test for properties file as well:

public class Test{

private HashMap<String, String> aTCN;

private static final String alpha= "alpha.";

private static final String beta = "beta.";

private Properties exporterConfig;

private static final ADFLogger LOG = ADFLoggerFactory.getLogger("R",R.class);

public Map<String, String> getATCN() {

if (aTCN== null) {

aTCN= new HashMap<>();

Properties demo= new Properties();

try {

demo.load(ClassLoader.getSystemResourceAsStream("r1.properties"));

} catch (IOException e) {

LOG.emitError("", e.getMessage());

}

for (String columnName : demo.stringPropertyNames()) {

aTCN.put(columnName.replace(beta, ""),

demo.getProperty(columnName).replace(alpha, ""));

}

}

return aTCN;

}

public Properties getEC() {

if (eC== null) {

try {

exporterConfig = new Properties();

exporterConfig.load(ClassLoader.getSystemResourceAsStream("r2.properties"));

} catch (IOException e) {

LOG.emitError("", e.getMessage());

}

}

return eC;

}

}

I was unable to figure out the same. Let me know if any one has any solution.

- 2of 2 votes
Given two sorted lists and an integer k, merge the lists up to a maximum of k elements.