#Problem Description:
# in a two-dimensional array (each one-dimensional array is the same length), each row is ordered in ascending order from left to right.
# Each column is sorted in ascending order from top to bottom. Please complete a function, enter such a two-dimensional array and a
# Integer that determines whether the array contains the integer.
Class solution: # Array Two-dimensional list def Find (self, Target, array): row = len (array)-1 #行数 col = Len (array[0 ])-1 #列数 i = 0 j = col while j>=0 and I<=row: if Array[i][j]>target: j-= 1 elif Array[i][j]<target: i+= 1 else: return True return False matrix = [[1,2,3,4],[2,3,4,5], [3,4,5,6],[4,5,6,7]]s = Solution () print (S.find (5,matrix))
#Summary:
#思维关键点是矩阵左下角或者右上角, if the lower left corner, than its small, row 1 continues to find, if compared to the large, column +1 continues to find, the upper right corner is the opposite
#技术总结 two ways to define the ① of a two-dimensional array: List or Numpy.array ()
#②list can be loaded with different types of elements int float Str,array can only fit the same type
#③ get Element Method list[0][1],array[0,1]
#④list convert array to call the array method in the NumPy module Np.array (list)
Two-dimensional array lookup