Amazon OA

amazon logo
amazon
July 6, 20256 reads

Summary

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

Full Experience

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

Interview Questions (2)

Q1
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]

Q2
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.

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

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