Driver Code
public static void main ( String [ ] args ) { int R = 5 ; int [ ] [ ] arr = { { 1 , 2 } , { 2 , 3 } , { 4 , 5 } } ; int [ ] queries = { 2 , 4 , 1 , 3 } ; int N = arr . length ; int M = queries . length ; findMaxValueOfSet ( arr , queries , R , N , M ) ; } }