二维数组双指针搜索正确性

167 https://leetcode-cn.com/problems/two-sum-ii-input-array-is-sorted/
633 https://leetcode-cn.com/problems/sum-of-square-numbers/
240 https://leetcode-cn.com/problems/search-a-2d-matrix-ii/

题解:https://leetcode-cn.com/problems/sum-of-square-numbers/solution/shuang-zhi-zhen-de-ben-zhi-er-wei-ju-zhe-ebn3/

典型:
一维数组搜索
双指针类型满足

  • 每行的元素从左到右升序排列。
  • 每列的元素从上到下升序排列。
    则,构建nums[i]+nums[j]的二维矩阵,起始点左右指针对应的位置为左上,每次移动即排除掉对应行、列的其他元素。
    在这里插入图片描述

posted on 2021-04-28 10:46  千羽12138  阅读(1)  评论(0)    收藏  举报  来源

导航