Driver Code
public static void main ( String [ ] args ) { n = 4 ; m = 4 ; X = 6 ; int grid [ ] [ ] = { { 3 , 2 , 6 , 1 } , { 1 , 9 , 2 , 4 } , { 4 , 1 , 3 , 9 } , { 3 , 8 , 2 , 1 } } ; int ans = maxSum ( grid ) ; System . out . println ( ans ) ; } }