Minimum Bitwise OR From Grid
You are given a 2D integer array grid of size m x n.
You must select exactly one integer from each row of the grid.
Return an integer denoting the minimum possible bitwise OR of the selected integers from each row.
Example 1
1 5 2 4
Input
grid = [[1,5],[2,4]]Output
3Choose 1 from the first row and 2 from the second row, and the bitwise OR of
1 | 2 = 3 is the minimum possible.Example 2
3 5 6 4
Input
grid = [[3,5],[6,4]]Output
5Choose 5 from the first row and 4 from the second row, and the bitwise OR of
5 | 4 = 5 is the minimum possible.Constraints
- 1 <= m == grid.length <= 10^5
- 1 <= n == grid[i].length <= 10^5
- m * n <= 10^5
- 1 <= grid[i][j] <= 10^5