Re: [闲聊] 每日LeetCode

楼主: Rushia (みけねこ的鼻屎)   2023-06-08 12:46:11
※ 引述《Rushia (みけねこ的鼻屎)》之铭言:
: https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix/description/
: 1351. Count Negative Numbers in a Sorted Matrix
: 给你一个排序好的 Matrix,找出该 Matrix 有几个非正整数。
: Example 1:
: Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]
: Output: 8
: Explanation: There are 8 negatives number in the matrix.
: Example 2:
: Input: grid = [[3,2],[1,0]]
: Output: 0
推 pandix: 这样跑到n^2了06/08 11:22
推 Che31128: 这题遍寻有办法跑n吗06/08 11:47
推 NTHUlagka: 这题应该能O(min(m,n)) 因为他rows column都是有序的06/08 12:04
1.可以从左下开始找,如果左下是正数的话上面的行都不用看了。
Java Code:
作者: pandix (面包屌)   2022-06-08 11:22:00
这样跑到n^2了
作者: Che31128 (justjoke)   2022-06-08 11:47:00
这题遍寻有办法跑n吗
作者: NTHUlagka (拉卡)   2022-06-08 12:04:00
这题应该能O(min(m,n)) 因为他rows column都是有序的
作者: wwndbk (黑人问号)   2023-06-08 12:54:00
大师
作者: JIWP (JIWP)   2023-06-08 12:59:00
大师

Links booklink

Contact Us: admin [ a t ] ucptt.com