Swiggy Online Assessment Question
Anonymous User
5338
  1. Mascot Travel

There is an excitation matrix A of the size NxM where A[i][j] signifies the excitation level of the node present in i th row and j th column.

All the excitation energy values in the matrix are non-negative.

Swiggy Mascot has to travel from the left most node in the first row to right most node in the last row using the least energy possible.

From a node on the matrix, Mascot is allowed to move in only four directions and in each move Mascot can take only one step i.e go one step vertically,

horizontally, to the right or to the left. The energy required for a move from one node to its adjacent node is the modulus difference between the excitation

energies of the nodes i.e if X, Y are the excitation energies of the two adjacent nodes then energy required for this step

is [X-YI.

Constraints:

1 < (N * M) <= 10^5

1 <= A[i][j] <= 10^9

Output Format:

Output will be a single non-negative

value.

Sample Input:

2 2

1  5

4 10

Sample Output:

5

Explanation:

Mascot will first move to the right and then bottom. The energy required for moving right is 15-11-4. The energy required to move bottom from there is 110-515. So, the total energy required is max(4, 5) = 5. We can't have any other path with lesser energy than this.

Any Suggestions please... I guess this will be solved using Dijkstra's Algorithm.

  1. Discussion in XYZ Problem Statment:

In XYZ company post taking interviews of candidates, there happens a de-brief session, where people sit around round tables and discuss interview's results. During early startup period there were around N core team members who used to take interviews. This is how they used to split up and discuss:

  1. They always used to split into 2 groups (each containing N/2 members) 2. Each group sits around a round table

Your task is to compute the number of distinct ways in which these N core team members can sit and discuss. Its always guaranteed N is an even number. Note: If configuration of 4 persons sitting around one table is [1,2,3,4] Other configurations like:[2,3,4,1], [3,4,1,2] are equal and should not be considered different.

Input Format:

You will be given a single integer N

Output Format:

Print a single line as output representing the answer to the problem.

Sample Input 0:

2

Sample Output 0:

Sample Input 1:

4

Sample Output 1:

3

Constraints:

2 <= N <= 20

N is an even number for proper division into 2 groups
  1. Maximising ABC Genie Pick Up Drop Off Revenues

A ABC Delivery Partner knows the pick-up and drop-off locations of parcels requested by customers using ABC's

Genie Service. All the locations are in km from the starting point. The starting

point is at 0 km.

For each km to transport a parcel, the Delivery Partner charges 1 unit of money

per parcel. Some Genie customers are even willing to pay an extra tip if the

Delivery Partner is ready to pick and

drop off their parcel. At any point of

time, the Delivery Partner can only deliver one parcel. Determine the

maximum amount the Delivery Partner can earn.

Example

pickup = [0, 2, 9, 10, 11, 12] drop= [5, 9, 11, 11, 14, 17]

tip= [1, 2, 3, 2, 2, 1]

The way to earn the most money is by accepting parcels at indices 1, 2 and 5.

• The amount paid by the customer at index 1:9-2+2=9

• The amount paid by the customer at index 2: 11-9+3=5

• The amount paid by the customer at index 5:17-12+1=6

• The total amount paid by the customers is 9+ 5+ 6 = 20

Therefore, the return value is 20.

Function Description

Complete the function

maximiseRevenue in the editor below. The function must return an integer denoting the maximum amount that can be earned by the Delivery Partner.

maximiseRevenue has the following

parameter(s):

pickup[pickup[0]....pickup[n-1]]: an array of n integers that denote the pickup location of the potential parcels drop[drop[0]....drop[n-1]]: an array of n integers that denote the drop-off locations of the potential parcels

tip[tip[0]...tip[n-1]]: an array of n

integers that denote the tips offered by each customer if their parcel is accepted for pick up and drop off```


Suggest how can we code to solve the problem

Comments (6)