Amazon OA

Posted
6 Jul 2025
280 reads

Summary

I encountered two specific algorithmic questions during my Amazon Online Assessment on Hackerrank.

How it went

2 questions asked on hackerrank. Don't know if these questions are mentioned elsewhere in Leetcode.

Questions asked (2)

  1. 01

    Maximize K Count in Array with One Subarray Modification

    Data Structures & Algorithms

    You are given an array arr = [6,4,4,6,4,4] and a target number k = 6 . You are allowed choose any subarray (i:j) from the array and add any number (X) you want to each element in the sub-array. You can perform this operation atmost once. Return the maximum possible count of k in the resultant array. eg. here if we add 2 to sub array from [1:5] the resultant array becomes - [6,6,6,8,6,6] and hence count(k=6) = 5 which is maximum. eg 2. arr = [2,5,2,5,2] & k = 2 => Output = 4 with arr = [2,2,-1,2,2]

  2. 02

    Maximize Number by Appending X or Y with Target Sum of Digits

    Data Structures & Algorithms

    You are given 2 integers (x,y) and a target count (n). Suppose (x=3, y = 4 and n = 13). You can form numbers by appending either 'x' or 'y' to your current number. eg (34, 43, 3443, 3444). Return the maximum number possible such that sum of digits (= n). Here possible numbers with n = 13 can be [3433, 4333, 3343 ..] with the maximum being = 4333. eg 2. x = 9, y = 7, n = 345.

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!