Wisetech Global OA

Anonymous User
516
Sep 09, 2022
Sep 09, 2022

No. of questions: 3
Time: 180 mins
Level : LC Medium - 2, Hard - 1

Q1: Same as this https://leetcode.com/discuss/interview-question/1759477/amazon-new-grad-oa-2022-find-lowest-price

Q2: Given a list of integers representing the number of products each supplier has and an integer representing the number of products sold, find the maximum profit the company can make.
Example 1:
Input: inventories = [6, 4] order = 4
Output: 19
Explanation:
There are two suppliers, with inventory of 4 and 6 respectively. A total of 4 items are ordered. We can make maximum profit by
selling 1 item from the first supplier for 6
selling 1 item from the first supplier for 5
selling 1 item from the first supplier for 4, which brings down the inventory of the first supplier to 3
selling 1 item from the second supplier for 4
The maximum profit is 6 + 5 + 4 + 4 = 19.

Contraints : 1 <= Order <= 10^18, suppliers <= 10^9
Note - Using MaxHeap gives TLE. Had to use HashMap + arithmetic progression sum based solution.

Q3: Connected graph with nodes mapped 0, 1 & 2, find the maximum distance between 0 & 2 labeled node.
Constraints: Nodes <= 10 ^ 5, edges <= nodes * (nodes - 1) /2
Note - Used BFS from all 0 nodes to find nearest 2 node. Ans would be maximum of all such paths. Got TLE. Any better idea?

Comments (2)