Problem 1521 · Hard

Find a Value of a Mysterious Function Closest to Target

Answer static range-AND queries in O(1) with a sparse table, then binary search each left end for the closest AND to the target.

Open the interactive visualisation