Maximize modulus by replacing adjacent pairs with their modulus for any permutation of given Array | Java Program to implement the above approach ; Function to find the maximum value possible of the given expression from all permutations of the array ; Stores the minimum value from the array ; Return the answer ; Driver Code
import java . io . * ; class GFG { static int maximumModuloValue ( int A [ ] , int n ) { int mn = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { mn = Math . min ( A [ i ] , mn ) ; } return mn ; } public static void main ( String [ ] args ) { int A [ ] = { 7 , 10 , 12 } ; int n = A . length ; System . out . println ( maximumModuloValue ( A , n ) ) ; } }