public class Solution
    {
        public bool SearchMatrix(int[,] matrix, int target)
        {
            int i = 0, j = matrix.GetLength(1) - 1;
            while (i < matrix.GetLength(0) && j >= 0)
            {
                int x = matrix[i, j];
                if (target == x)
                {
                    return true;
                }
                else if (target < x)
                {
                    j--;
                }
                else
                {
                    i++;
                }
            }
            return false;
        }
    }

 

posted on 2018-10-04 15:57  Sempron2800+  阅读(103)  评论(0编辑  收藏  举报