1 public class Solution 2 { 3 public bool Find(int target, int[][] array) 4 { 5 if (array != null) 6 { 7 int rowCnt = array.Length - 1; 8 int colCnt = ...
1 public class Solution 2 { 3 public bool Find(int target, int[][] array) 4 { 5 if (array != null) 6 { 7 int rowCnt = array.Length - 1; 8 int colCnt = array[0].Length - 1; 9 10 int row = 0; 11 int col = colCnt; 12 13 while (row <= rowCnt && col >= 0) 14 { 15 if (target == array[row][col]) 16 { 17 return true; 18 } 19 else if (target < array[row][col]) 20 { 21 col--; 22 } 23 else 24 { 25 row++; 26 } 27 } 28 return false; 29 } 30 31 return false; 32 } 33 }