Concise Java Solution


#1

public class Solution {
public int searchMatrix(int[][] A, int B) {
int row = 0;
int col = A[0].length-1;

    while(row < A.length && col >= 0) {
        int ele = A[row][col];
        if(ele == B)
            return 1;
        else if(ele < B)
            row++;
        else 
            col--;
    }
    
    return 0;
}

}