int left = 0, right = m * n - 1; int pivotIdx, pivotElement; while (left <= right) { pivotIdx = (left + right) / 2;//中间点 pivotElement = matrix[pivotIdx / n][pivotIdx % n];//中间点在二维矩阵中位置 if (target == pivotElement) return true; else { if (target < pivotElement) right = pivotIdx - 1; else left = pivotIdx + 1; } }
求数组长度
s.length
字符串长度
s.length()