Search
⌘K

Leetcode 1521. Find a Value of a Mysterious Function Closest to Target

Given an array and a target, find the minimum absolute difference between target and the bitwise AND of any subarray arr[l..r]. The core challenge is to avoid O(n^2) checks by using the monotone/decreasing property of subarray ANDs (there are few distinct AND values ending at each index).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.