i am writing the function to check if the given value is included in the matrix in . This matrix has the following properties: •Integers in each row are sorted in ascending from left to right. •Integers in each column are sorted in ascending from top to bottom
public static boolean searchMatrix(int target, int[][] matrix)
{
for(int i = 0;i <= matrix[0].length;i++)
{
for (int j=i; j<matrix.length;j++)
{
if(target == matrix[i][j])
return true;
}
}
return false;
}
i want to know weather this program has time complexity of O(N). if not what changes should i make to get into O(N).