AMAZON Coding Question – Solved

9 Live
There are m cities in a 1-dimensional country, where each city is represented by an integer between 1 through m. There are n Amazon warehouses, where the ith warehouse can deliver to cities in the range cityStart[i] to cityEnd[i] for better delivery management. For example, if there are m = 10 cities, and n = 2 warehouses cityStart = [3, 1] and cityEnd = [10, 5] then the first warehouse delivers to cities from 3 to 10 and the second one delivers from cities 1 to 5. Thus the cities 3, 4, and 5 are served by 2 warehouses and all others are served by exactly one. Define F(x) as the number of warehouses that can deliver to the xth city. The growth coefficient is F(1)^F(2) .... F(m-1)^F(m), where "A" is the bitwise XOR operator. Given the delivery ranges of all the Amazon warehouses, find Amazon's growth coefficient. Note: The bitwise XOR operator (^) returns a 1 in each bit position for which the corresponding bits of either but not both operands are 1s. . 12 = 00001100 (In Binary) . 25 = 00011001 (In Binary) . Bitwise XOR Operation of 12 and 25 00001100 00011001 = 00010101 = 21 (In decimal) Example cityStart = [1,1, 2] cityEnd = [1, 3, 4] m=4 In the above example, the number of cities m = 4 and the number of warehouses n = 3.

Asked in: AMAZON

Image of the Question

Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |