Amazon Online Assesment OA | HackerRank | 2025
Summary
I recently completed my Amazon SDE I Online Assessment (OA) on HackerRank, facing two questions. I was able to solve the first question but failed the assessment due to running out of time and insufficient practice with Monotonic Stack problems.
Full Experience
I recently applied for Amazon SDE I Role and got a email to attend the OA round on HackerRank.
Here are the questions they asked me:
Q1.
There is an input stockData list of prices of a stock on each day. Where stockData[i] is the stock's price on the ith day.
Then there is a input list queries, where queries[j] is an index in stockData.
Note: Both lists are 1-based and not 0-based sorry for the confusion.
For each queries[j], check if the value of the stock on the jth has a lower value on the j - 1 day, if yes then that is the answer, otherwise check j+1 day, if it is lower than value on jth day then that is the answer. If both are not lower, then check the j-2 and j+2 days and so on until you find a lower value than queried day. If no lower value is found the anser is -1
Basically the find the Nearest Lower Number and in case of a tie, prefer the left side value.
1) Case 1
Input: stockData = [5,6,8,4,9,10,8,3,6,4], queries = [6,5,4]
Output: [5,4,8]
2) Case 2
Input: stockData = [2,1,3], queries = [2,1]
Output: [-1,1]
Q2. I don't remember the Q2 but it was also a Monotonic Stack based question.
I could only solve the first question and my time ran out. Because of my lack of practice of Monotonic Stack problems.
Verdict: Failed.
Interview Questions (1)
Nearest Lower Number in Stock Data
There is an input stockData list of prices of a stock on each day. Where stockData[i] is the stock's price on the ith day.
Then there is a input list queries, where queries[j] is an index in stockData.
Note: Both lists are 1-based and not 0-based sorry for the confusion.
For each queries[j], check if the value of the stock on the jth has a lower value on the j - 1 day, if yes then that is the answer, otherwise check j+1 day, if it is lower than value on jth day then that is the answer. If both are not lower, then check the j-2 and j+2 days and so on until you find a lower value than queried day. If no lower value is found the anser is -1
Basically the find the Nearest Lower Number and in case of a tie, prefer the left side value.
1) Case 1
Input: stockData = [5,6,8,4,9,10,8,3,6,4], queries = [6,5,4]
Output: [5,4,8]
2) Case 2
Input: stockData = [2,1,3], queries = [2,1]
Output: [-1,1]
Preparation Tips
Tips: This was my first OA round on HackerRank, I struggled with the interface, make sure that you practice on HackerRank.