AMAZON Coding Question – Solved

10 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

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |