Saddle Point
Given a matrix of n x n size, the task is to find saddle point of the matrix. A saddle point is an element of the matrix such that it is the minimum element in its row and maximum in its column. Examples: Input: Mat[3][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}} Output: 7 7 is minimum in its row and maximum in its column. Input: Mat[3][3] = {{1, 2, 3}, {4, 5, 6}, {10, 18, 4}} Output: No saddle point import java.io.*; class SaddlePoint { public void displayPoint() throws IOException { BufferedReader br= new BufferedReader( new InputStreamReader(System.in)); System.out.print( "Enter no of rows: " ); int r=Integer.parseInt(br.readLine()); System.out.print( "Enter no of columns: " ); int c=Integer.parseInt(br.readLine()); int [][]arr= new int [r][c]; int stR= 0 ; //To store the row index of ...

Comments
Post a Comment