Find the minimum value of the given expression over all pairs of the array | Java program to find the minimum value of the given expression over all pairs of the array ; Function to find the minimum value of the expression ; Iterate over all the pairs and find the minimum value ; Driver code
import java . io . * ; import java . util . Arrays ; class GFG { static int MinimumValue ( int a [ ] , int n ) { int answer = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { answer = Math . min ( answer , ( ( a [ i ] & a [ j ] ) ^ ( a [ i ] a [ j ] ) ) ) ; } } return answer ; } public static void main ( String [ ] args ) { int N = 6 ; int [ ] A = new int [ ] { 12 , 3 , 14 , 5 , 9 , 8 } ; System . out . print ( MinimumValue ( A , N ) ) ; } }