My accepted c# code. why there has no one solve the problem by c# ?


  • 0
    public class Solution {
        public bool SearchMatrix(int[,] matrix, int target) 
        {
                int target_lvl=0;
                int uuper = matrix.GetUpperBound(0);
                int llowr = matrix.GetLowerBound(0);
                long num = matrix.GetLength(1)-1;
                bool gofor = false;
                for (int i = 0; i <= uuper; i++)
                {
                    if (target <= matrix[i,num])
                    {
                        target_lvl = i;
                        gofor = true;
                        break;
                    }
                }
                if(gofor)
                {
                    for (int i = 0; i <= num; i++)
                    {
                        if (target == matrix[target_lvl,i])
                        {
                            return true;
                        }
                    }
                }
                return false;
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.