Skip to content

Commit 6d9fb49

Browse files
authored
Update 699-falling-squares.js
1 parent aba904e commit 6d9fb49

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

699-falling-squares.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ function fallingSquares(positions) {
1414
const res = []
1515
let h = 0
1616
for (let pos of positions) {
17-
let cur = new Interval(pos[0], pos[0] + pos[1] - 1, pos[1])
17+
let cur = new Interval(pos[0], pos[0] + pos[1], pos[1])
1818
h = Math.max(h, getHeight(intervals, cur))
1919
res.push(h)
2020
}
21+
console.log(intervals)
2122
return res
2223
}
2324
function getHeight(intervals, cur) {
2425
let preMaxHeight = 0
2526
for (let i of intervals) {
26-
if (i.end < cur.start) continue
27-
if (i.start > cur.end) continue
27+
if (i.end <= cur.start) continue
28+
if (i.start >= cur.end) continue
2829
preMaxHeight = Math.max(preMaxHeight, i.height)
2930
}
3031
cur.height += preMaxHeight

0 commit comments

Comments
 (0)