Position of the K-th One — Solution & Editorial
Precompute the positions of all ones in order; each query indexes that list.
Complexity: O(length + Q)
Precompute the positions of all ones in order; each query indexes that list.
Complexity: O(length + Q)