Amazon · Software Engineer
Rounds
- Coding round
Questions asked
- Given an integer array
valuesand integerk, maximize occurrences ofk. - For any subarray, you can add or subtract the same value to all elements in the subarray (the value applies to all elements in the subarray).
- You can only add or subtract by a value in one subarray. Maximize occurrences of
k.
Tips
- Think about how changing a subarray can align its values to
k, and how to choose the optimal subarray. - Try to use prefix sums to efficiently calculate the effect of changing different subarrays.
