Maximum OR sum of sub | Java program to find maximum OR sum ; function to find maximum OR sum ; OR sum of all the elements in both arrays ; Driver code
class GFG { static void MaximumSum ( int a [ ] , int b [ ] , int n ) { int sum1 = 0 , sum2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum1 |= a [ i ] ; sum2 |= b [ i ] ; } System . out . println ( sum1 + sum2 ) ; } public static void main ( String arg [ ] ) { int A [ ] = { 1 , 2 , 4 , 3 , 2 } ; int B [ ] = { 2 , 3 , 3 , 12 , 1 } ; int n = A . length ; MaximumSum ( A , B , n ) ; } }