一、二维数组转一维数组 [ [a, b] ] => [ c, d ]
    一维数组的 index = row * 二维下标x + 二维下标y

    一维数组转二维数组 matrix = [ [a, b] ]
    二维下标 X = Math.floor(index / row)
    二维下标 Y = Math.floor(index % row)

    1. /**
    2. * @param {number[][]} matrix
    3. * @param {number} target
    4. * @return {boolean}
    5. */
    6. var searchMatrix = function (matrix, target) {
    7. if(matrix === null || !matrix.length) return false
    8. let row = matrix[0].length,
    9. col = matrix.length,
    10. l = 0,
    11. r = (col - 1) * row + row - 1
    12. while (l <= r) {
    13. const m = Math.floor(l + (r - l) / 2)
    14. const cur = matrix[Math.floor(m / row)][Math.floor(m % row)]
    15. if(cur === target) return true
    16. if(cur > target) {
    17. r = m - 1
    18. } else {
    19. l = m + 1
    20. }
    21. }
    22. return false
    23. };