题解 | #二维数组中的查找#

二维数组中的查找

https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e

function Find(target, array){
            let row = array.length - 1;
            let col = 0;
            while(row >= 0 && col < array[0].length){
                if(array[row][col] === target){
                    return true;
                }else if(array[row][col] > target){
                    row--;
                }else{
                    col++;
                }
            }
            return false;
        }

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务