Recent Amazon OA Questions | 2025
- Posted
- 15 May 2025
Summary
I recently completed an Amazon Online Assessment for an SDE position, which included two specific coding questions administered on the HackerRank platform.
How it went
Recently I give Amazon OA for SDE position. There were 2 Coding Question on HackerRank platform.
Please find the solutions here : https://leetcode.com/discuss/post/6748169/recent-amazon-oa-solutions-2025-by-anony-1hp7/
Question 1
The data engineers at Amazon are working on partitioning their server chains. There is a linear chain of n servers numbered from 1 to n, where the cost parameter associated with the ith server is represented by the array cost[i]. These servers need to be partitioned into exactly k different server chains. The cost of partitioning a server chain servers[i: j] is defined as cost[i] + cost[j]. The total cost is the sum of the partitioning cost of each server chain.
Given n servers, an array cost and an integer k, find the minimum and maximum possible total cost of the operations and return them in the form of an array of size 2: [minimum cost, maximum cost].
Note: Partitioning of an array means splitting the array sequentially into two or more parts where each element belongs to exactly one partition. For an array [1, 2, 3, 4, 5], a valid partition would be [[1], [2, 3], [4, 5]], while [[1, 2], [2, 3], [4, 5]] and [[1, 3], [2, 4, 5]] would be considered invalid partitions.
Question 2
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.
Task:
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 query.
Note:
If for some query, all the numSkills received a request in the given time interval, then the answer is 0.
Questions asked (2)
- 01
Partition Server Chains for Min/Max Cost
Data Structures & Algorithms
The data engineers at Amazon are working on partitioning their server chains. There is a linear chain of n servers numbered from 1 to n, where the cost parameter associated with the ith server is represented by the array cost[i]. These servers need to be partitioned into exactly k different server chains. The cost of partitioning a server chain servers[i: j] is defined as cost[i] + cost[j]. The total cost is the sum of the partitioning cost of each server chain.
Given n servers, an array cost and an integer k, find the minimum and maximum possible total cost of the operations and return them in the form of an array of size 2: [minimum cost, maximum cost].
Note: Partitioning of an array means splitting the array sequentially into two or more parts where each element belongs to exactly one partition. For an array [1, 2, 3, 4, 5], a valid partition would be [[1], [2, 3], [4, 5]], while [[1, 2], [2, 3], [4, 5]] and [[1, 3], [2, 4, 5]] would be considered invalid partitions.
- 02
Alexa Skill Request Log Analysis
Data Structures & Algorithms
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.
Task:
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 query.Note:
If for some query, all the numSkills received a request in the given time interval, then the answer is 0.