Uber's real-time systems collect a sequence of operational signals during trips, such as pricing flags, route conditions, safety checks, and driver availability indicators. Each signal is represented as an integer where different bits correspond to different system flags.
Uber wants to build a utility that analyzes these signals over continuous time windows. The utility takes an array of integers arr of size n, representing the signal values over time, and an integer k & returns the kth largest combined signal strength computed using bitwise OR over all possible contiguous windows of the signal array.
Given the array arr and the integer k, implement this utility to return the kth largest bitwise OR sum as described.
The bitwise OR sum of a signal window starting at index l and ending at index r is given by arr[l] | arr[l+1] | ... | arr[r].
A subarray represents a contiguous window of Uber signals. For example, the subarrays of [1, 2, 3] are [1], [1, 2], [1, 2, 3], [2], [2, 3], and [3].
Medium