Amazon OA | Subarray with Maximum Bitwise AND

Result
Ongoing
Posted
1 Sept 2025
341 reads

Summary

I completed an Amazon Online Assessment which featured a problem focused on finding the maximum bitwise AND of a subarray, with the allowance to increment array elements a limited number of times.

How it went

I recently took an Online Assessment for Amazon. The assessment featured a particularly interesting problem where I needed to find the maximum bitwise-AND of a subarray of a given size m, with the constraint of being able to increment any number in the array at most k times. I found the problem to be quite a brain-teaser, especially optimizing for the bitwise AND property across different subarrays.

Questions asked (1)

  1. 01

    Maximize Subarray Bitwise AND with K Increments

    Data Structures & Algorithms · Hard

    Given n sized array of integers,

    find the maximum bitwise-AND of a subarray of size m

    You can add 1 (increment) to any number in the array, atmost k times.

    Example 1 :

    n = 4
    arr : [1,4,10,2]
    k = 8
    m = 2
    

    Ans : 10

    Increment the last element 2 -> 10 Hence the maximum subarray bitwise would be 10

    Example 2 :

    n = 3
    arr = [1,1,1]
    k = 3
    m = 3

    Ans : 2 Add 1 to each element of the array -> [2,2,2] Hence the maximum subarray bitwise would be 2

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Amazon recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

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