cswork / libraryOpen practice workspace

Interview experiences · Amazon

Amazon Software Engineer Interview Experience — Online Assessment Coding Question on Maximizing a Bitwise AND

OAInterviewed 2026-09

Fresh out of the oven. I found the coding question really confusing. I spent a long time thinking and guessing, and I guessed bitwise AND, which turned out to be wrong. Afterwards I went back over it with Claude, and the approach it gave me was greedy + bit manipulation. Here is the summary: Problem: Given an array Arr, a count K, and a budget C. You can distribute C total "capacity" as increases…

Fresh out of the oven. I found the coding question really confusing. I spent a long time thinking and guessing, and I guessed bitwise AND, which turned out to be wrong. Afterwards I went back over it with Claude, and the approach it gave me was greedy + bit manipulation.

Here is the summary:

Problem:
Given an array Arr, a count K, and a budget C. You can distribute C total "capacity" as increases to any elements (you choose how much to add to which elements, as long as the total added doesn't exceed C). After that, you pick any K elements (not necessarily contiguous) to maximize the bitwise AND of those K values.

Example:
[5, 4, 1, 7, 2], K=3, C=3, output -> 6. Pick 4, 5, 6 -> after allocating they become 6, 6, 7 -> 6 & 6 & 7 -> 6

I went down the wrong path and got it quite badly wrong. I don't know whether I can still pass. Sharing it with everyone.

Comments

Nothing here yet.

Join in on CSWork →