Skip to content

Commit 542e441

Browse files
committed
1277
1 parent e0d01b7 commit 542e441

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# @param {Integer[][]} matrix
2+
# @return {Integer}
3+
def count_squares(matrix)
4+
count = 0
5+
(0...matrix.length).each { |i|
6+
(0...matrix[0].length).each { |j|
7+
if matrix[i][j] == 1 && i > 0 && j > 0
8+
matrix[i][j] += [matrix[i][j-1], matrix[i-1][j], matrix[i-1][j-1]].min
9+
end
10+
count += matrix[i][j]
11+
}
12+
}
13+
14+
count
15+
end

0 commit comments

Comments
 (0)