Bitwise OR of all unordered pairs from a given array | Java program to implement the above approach ; Function to find the bitwise OR of all possible pairs of the array ; Stores bitwise OR of all possible pairs of arr [ ] ; Traverse the array arr [ ] ; Update totalOR ; Return bitwise OR of all possible pairs of arr [ ] ; Driver Code
import java . util . * ; class GFG { static int TotalBitwiseORPair ( int arr [ ] , int N ) { int totalOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { totalOR |= arr [ i ] ; } return totalOR ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 12 , 15 } ; int N = arr . length ; System . out . print ( TotalBitwiseORPair ( arr , N ) ) ; } }