As reported: Amazon online assessment (2025), one coding question.
You are given an integer array arr of size n, and integers k and m. You may increase elements by 1, at most k times in total (the same element may be increased many times). Afterwards, choose a subarray of length exactly m. Return the maximum possible bitwise AND of the chosen subarray.
Example 1
arr = [1,1,1], k = 3, m = 3
Output: 2 add 1 to each element: [2,2,2]
Example 2
arr = [5,3,8,6], k = 3, m = 2
Output: 8 raise 6 to 8 (2 increments): the subarray [8,8]
Constraints: 1 ≤ m ≤ n ≤ 10⁵; 0 ≤ arr[i] ≤ 10⁹; 0 ≤ k ≤ 10⁹.
Code runner format: three lines: arr as a JSON array, then k, then m. Implement maxSubarrayAnd(arr, k, m); the harness prints the result.