Find Idle Skills Query
Learn this problemProblem statement
The Amazon Alexa development team needs to analyze request logs across numSkills different Alexa skills to understand their performance and user engagement.
The skills are indexed from 1 to numSkills, and the logs are provided as a 2D array requestLog of size m where requestLog[i] = [skill_ID, timeStamp] represents a request made at timeStamp to the skill with ID skill_ID.
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 query.
Note: If for some query in the numSkills received requestLog the given time interval for that query, then answer is 0.
Function
findIdleSkillsQuery(numSkills: int, requestLogs: int[][], queryTime: int[], timeWindow: int) → int[]
Complete the function findIdleSkillsQuery in the editor.
findIdleSkillsQuery has the following parameters:
int numSkills: an integer denoting the number of skillsint[][] requestLogs: 2D array denoting the request logsint[] queryTime: an integer array denoting the query timesint timeWindow: an integer denoting the lookback period for queriesReturns
int[]: an integer array denoting the answers to the queries
🌷 A super special thanks to an old friend who kindly helped out! 🌷
Examples
Example 1
numSkills = 3requestLogs = [[1, 3], [2, 6], [1, 5]]queryTime = [10, 11]timeWindow = 5return = [1, 2]
Example 2
numSkills = 6requestLogs = [[3, 2], [4, 3], [2, 6], [6, 3]]queryTime = [3, 2, 6]timeWindow = 2return = [3, 5, 5]Example 3
numSkills = 6requestLogs = [[3, 2], [4, 3], [2, 6], [6, 3]]queryTime = [1, 2, 3, 4, 5, 6]timeWindow = 1return = [6, 5, 3, 4, 6, 5]Constraints
1 ≤ numSkills ≤ 10^51 ≤ m ≤ 10^51 ≤ q ≤ 10^51 ≤ requestLogs[i][0] ≤ n1 ≤ requestLogs[i][1] ≤ 10^51 ≤ queryTime[i] ≤ 10^51 ≤ timeWindow ≤ 10^5
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026