#3806

Maximum Bitwise AND After Increment Operations

hard · 31.2% accepted · 75 likes · top 9%

array · greedy · bit manipulation · sorting

Description

You are given an integer array nums and two integers k and m.

You may perform at most k operations. In one operation, you may choose any index i and increase nums[i] by 1.

Return an integer denoting the maximum possible bitwise AND of any subset of size m after performing up to k operations optimally.

Solution