AMAZON Coding Question β Solved
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