-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path221.maximal-square.cpp
More file actions
40 lines (39 loc) · 843 Bytes
/
221.maximal-square.cpp
File metadata and controls
40 lines (39 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* @lc app=leetcode id=221 lang=cpp
*
* [221] Maximal Square
*
* https://leetcode.com/problems/maximal-square/description/
*
* algorithms
* Medium (31.43%)
* Total Accepted: 151.9K
* Total Submissions: 444.3K
* Testcase Example:
* '[["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]'
*
* Given a 2D binary matrix filled with 0's and 1's, find the largest square
* containing only 1's and return its area.
*
* Example:
*
*
* Input:
*
* 1 0 1 0 0
* 1 0 1 1 1
* 1 1 1 1 1
* 1 0 0 1 0
*
* Output: 4
*
*/
class Solution {
public:
maximalSquareCalculator() {}
int maximalSquare(std::vector<std::vector<char>>& matrix) {
int largestSquareSize = 0;
std::vector<int> largestSquareForPreviousLine(matrix.size(), 0);
int largestSquareForPreviousIndex = 0;
}
};