Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
4,882 views

All past online assesments of Amazon can be found using the tag "amazon_oa" in the search bar.

Here is the link : https://www.desiqna.in/tag/amazon_oa

in Online Assessments by Expert (34,270 points)
edited by | 4,882 views

1 Answer

0 like 0 dislike

Q1: Given array, delete the maximum contiguous subarray of size k from the original array and return the sum
 

 

Approach: Find maximum contiguous subarray sum of size k, subract from the sum of original array

 


Q2: Given array, return the index of the least absolute difference of the averages from two parts of the array
Testcase 1:
5
1 3 2 4 5
Output:
1

 

Explanation:
Index 1: [1], [3,2,4,5]
Averages are 1 and 3 respectively (floor is mentioned in the question)
abs(1 - 3) = 2
Index 2: [1,3], [2,4,5]
Averages are 2, 3
abs(2 - 3) = 1
Index 3: [1,3,2], [4,5]
Averages are 2, 4
abs(2 - 4) = 2
Index 4: [1,3,2,4], [5]
Averages are 2, 5
abs(2 - 5) = 3

 

Index 2 has least difference, so return 2

by Expert (34,270 points)
edited by