Amazon | Online Assessment | SDE 2 | Continuous Subarray Sum Variation?
Anonymous User
1909

Q1: Exactly the same https://leetcode.com/discuss/interview-question/1759164/Amazon-or-OA-or-Get-heaviest-package
15/15

Q2:
Input: list of ints
Output: sum of 'powers' of contiguous subarrays modded by a constant value as an int

powers is defined as:
image

eg input: : [2, 3, 2, 1]
output: 69

I came up with brute force O(n^2) approach, but it only passes 8/15 cases. Any chance to pass OA?

What's the optimal solution? Seems a bit similar to: https://leetcode.com/problems/continuous-subarray-sum/ but I can't figure it out.

Would you consider this medium or hard difficulty? I was expecting this OA to be a breeze, but wow I feel so dumb right now

update: OA got flagged for a manual review and i cleared it

Comments (7)