amazon logo
Amazon· SDE I

Amazon Online Assesment OA | HackerRank | 2025

Posted
5 Jul 2025
312 reads

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.

How it went

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.

Questions asked (1)

  1. 01

    Nearest Lower Number in Stock Data

    Data Structures & Algorithms

    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]

How they prepared

Tips: This was my first OA round on HackerRank, I struggled with the interface, make sure that you practice on HackerRank.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Amazon recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!