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

二维数组中的查找

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

一开始就想着肯定有技巧 想不出来只能暴力 无奈二分多么奇妙多么灵活

function Find(target, array)
{
    // write code here
    let bottom=array.length-1
    let right=array[0].length-1
    let n=right
    let m=0
    let pivot
    while(m<=bottom && n>=0){
     pivot=array[m][n]
    if(target===pivot){
        return true
    }
    if(target>pivot) {
        m+=1
    }
    if(target<pivot){
       n-=1
    }       
  }
    return false
}
module.exports = {
    Find : Find
};
全部评论

相关推荐

05-23 20:31
已编辑
武汉大学 Java
内向的柠檬精在研究求职打法:注意把武大标粗标大 本地你俩不是乱杀
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务