本文主要是介绍LCR 121. 寻找目标值 - 二维数组,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
解题思路:
根据大小消去行和列
class Solution {public boolean findTargetIn2DPlants(int[][] plants, int target) {int i = plants.length - 1, j = 0;while(i >= 0 && j <= plants[0].length-1){if(plants[i][j] > target) i--;else if(plants[i][j] < target) j++;else return true;}return false;}
}
这篇关于LCR 121. 寻找目标值 - 二维数组的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!