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
}
相关推荐
kgduu1 小时前
go-ethereum之rpc
开发语言·rpc·golang
dragoooon342 小时前
[优选算法专题六.模拟 ——NO.40~41 外观数列、数青蛙]
数据结构·算法·leetcode
一匹电信狗2 小时前
【C++】封装红黑树实现map和set容器(详解)
服务器·c++·算法·leetcode·小程序·stl·visual studio
flashlight_hi7 小时前
LeetCode 分类刷题:141. 环形链表
javascript·算法·leetcode
Kt&Rs9 小时前
11.9 LeetCode 题目汇总与解题思路
算法·leetcode
ゞ 正在缓冲99%…9 小时前
leetcode1547.切棍子的最小成本
数据结构·算法·leetcode·动态规划
2401_841495649 小时前
【LeetCode刷题】移动零
数据结构·python·算法·leetcode·数组·双指针法·移动零
开心星人10 小时前
Leetcode hot100 Java刷题(二)
java·算法·leetcode
hn小菜鸡10 小时前
LeetCode 153.寻找旋转排序数组中的最小值
数据结构·算法·leetcode
古城小栈12 小时前
Go 1.25 发布:性能、工具与生态的全面进化
开发语言·后端·golang