Amazon OA experience + question | 6M SDE INTERN | INDIA
Anonymous User
1971

Today i gave my OA for amazon 6M internship india. The OA had 41 questions across 9 sections like hands on programming, data structures, linux, algorithms, pseudocode, networks, software planning, database, one more section i dont remember.
In hands on programming there was only one question to be solved.
so in total 1 coding question and rest 40 mcq questions. total test duration was 90 minutes.

here is the question, please share your solution. Also let me know what is the difficulty of this problem -

Tyler durden is a salesperson and is assigned a task to travel to sell soaps. He must travel to different countries with S states each. His manager has also provided him with an integer array of A, of length N. Array A represents a rating list which shows the past sales in a certain state. Below are a few ules for him to follow to increase the efficiency of his travel :-

  • tyler should begin his travel from the state which has the lowest rating
  • when he starts his travel in a country, he should visit all the states in that country before going to a different country

Your task is to help tyler plan his travel route and return an integer value representing the country and the rating of the state tyler will be travelling to in month M based on the rating list.

NOTE -

  1. The rating list contains data for all the states together, so the first S ratings are for country 1, the next S ratings are for country 2 and so on.
  2. The month count starts from 1 and if two or more countries have same lowest rating then choose the country whose states has the second lowest rating.

Input -
Input1 : An integer value N, representing the length of rating list
Input2 : An integer value S, representing the number of states in a country
Input3 : An integer value M, representing the month numbers
Input4 : An integer array A, representing the rating list

Output -
Output1 : Return the country tyler will be travelling to in month M based on the rating list
Output2 : Return the state tyler will be travelling to in month M based on the rating list

Example 1 -
Input1 : 6
Input2 : 3
Input3 : 6
Input4 : {2, 1, 9, 3, 1, 4}

Output1 : 2
Output2 : 4

Explanation - there are 6 states, and each country has 3 states.
route will be country 1 --> country 2 (since the lowest rating is same in both the countries, we look at the second lowest rating and thus tyler will start his travel with country 1)

  • country 1 : 1 ---> 2 ---> 9
  • country 2 : 1 ---> 3 ---> 4
    using this tyler will be in country 2 and state 4 during the 6th month.

Example 2 -
Input1 : 12
Input2 : 3
Input3 : 7
Input4 : {4, 5, 7, 9, 3, 2, 5, 1, 3, 2, 4, 1}

Output1 : 2
Output2 : 2

Explanation - there are 12 states, and each country has 3 states.
route will be country 4 --> country 3 --> country 2 ---> country 4 (since the lowest rating is same in countries 4 and 3, we look at the second lowest rating and thus tyler will start his travel with country 4)

  • country 4 : 1 ---> 2 ---> 4
  • country 3 : 1 ---> 3 ---> 5
  • country 2 : 2 ---> 3 ---> 9
  • country 1 : 4 ---> 5 ---> 7
    using this tyler will be in country 2 and state 2 during the 7th month.

prewritten code :

//two libraries were included here which i don't remember
Struct Result {
	int output1;
	int output2;
};

Result profitDevelopment(int input1, int input2, int input3, int input4[]) {
	//write your code from here
}
Comments (4)