AMAZON Coding Question – Solved

2 Live
The Amazon Alexa development team needs to analyze request logs across numSkills different Alexa skills to ensure optimal performance and user engagement. The skills are indexed from 1 to numSkills, and the logs are provided as a 2D array requestLogs of size m, where requestLogs[i] = [skill_ID, timeStamp] denotes that a request was made to the skill with ID skill_ID at the time timeStamp. You are given an integer numSkills, a 2D integer array requestLogs, an integer timeWindow (representing a lookback period), and an array of queryTimes containing q queries. For each queryTime[i], determine the number of skills that did not receive a request in the time interval [queryTime[i] - timeWindow, queryTime[i]]. Return an array of length q containing the result of each of the queries. Note: If for some query all the numSkills received request in the given time interval for that query, then answer is 0. Example: Suppose numSkills = 3, timeWindow = 5, requestLogs = [[1, 3], [2, 6], [1, 5]], and queryTime = [10, 11] queryTime = 10 Time Interval = [10 - 5, 10] = [5, 10] Skills that received a request in the given interval = 1, 2 Skills not receiving a request in the given interval = 2 queryTime = 11 Time Interval = [11 - 5, 11] = [6, 11] Skills that received a request in the given interval = 1, 3 Skills not receiving a request in the given interval = 1, 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… |