Golang | Leetcode Golang题解之第240题搜索二维矩阵II

题目:

题解:

Go 复制代码
func searchMatrix(matrix [][]int, target int) bool {
    m, n := len(matrix), len(matrix[0])
    x, y := 0, n-1
    for x < m && y >= 0 {
        if matrix[x][y] == target {
            return true
        }
        if matrix[x][y] > target {
            y--
        } else {
            x++
        }
    }
    return false
}
相关推荐
fqq36 小时前
力扣刷题前置Java语法
算法·leetcode·职场和发展
半夏微凉半夏殇9 小时前
x11与weston对比,优先选哪个
leetcode·均值算法·eclipse
爱编程的小新☆14 小时前
【LeetCode】从递归到 Flood Fill:5 道题吃透 DFS 的选择、回溯与标记
java·算法·leetcode·深度优先·回溯·flood fill
evans在进步14 小时前
LeetCode 33:搜索旋转排序数组——Java 两阶段二分查找详解
java·python·leetcode
alphaTao14 小时前
LeetCode 每日一题 2026/8/10-2026/8/16
算法·leetcode
Forever Nore15 小时前
LeetCode 13 罗马数字转整数 - 按规则处理
linux·服务器·leetcode
旖旎夜光17 小时前
LeetCode 904:水果成篮(滑动窗口) —— 题解
数据结构·c++·算法·leetcode·滑动窗口
ZC跨境爬虫17 小时前
LeetCode 27. 移除元素(双指针详解 + Java Python 多解法对比)
java·python·leetcode
圣殿骑士-Khtangc18 小时前
Go错误处理最佳实践进阶从error到panic的完整指南
golang
运维开发笔记19 小时前
3.6 Go defer 语句学习笔记
golang