Find subsequences with maximum Bitwise AND and Bitwise OR | Function to find the maximum sum ; Maximum AND is maximum element ; Maximum OR is bitwise OR of all . ; Driver code
function maxSum ( a , n ) { var maxAnd = Math . max ( ... a ) ; var maxOR = 0 ; for ( var i = 0 ; i < n ; i ++ ) { maxOR |= a [ i ] ; } document . write ( ( maxAnd + maxOR ) ) ; } var n = 4 ; var a = [ 3 , 5 , 6 , 1 ] ; maxSum ( a , n ) ;