562.Longest-Line-of-Consecutive-One-in-Matrix
562. Longest Line of Consecutive One in Matrix
题目地址
https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix/
题目描述
Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal or anti-diagonal.
Example:
Input:
[[0,1,1,0],
[0,1,1,0],
[0,0,0,1]]
Output: 3
Hint: The number of elements in the given matrix will not exceed 10,000.代码
Approach #1 Brute Force
Time: O(N^2) && Space: O(1)
Approach #3 3D Dynamic Programming
Time complexity && Space complexity : O(mn)
Approach #3 2D Dynamic Programming
Last updated
Was this helpful?