We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aba904e commit 6d9fb49Copy full SHA for 6d9fb49
699-falling-squares.js
@@ -14,17 +14,18 @@ function fallingSquares(positions) {
14
const res = []
15
let h = 0
16
for (let pos of positions) {
17
- let cur = new Interval(pos[0], pos[0] + pos[1] - 1, pos[1])
+ let cur = new Interval(pos[0], pos[0] + pos[1], pos[1])
18
h = Math.max(h, getHeight(intervals, cur))
19
res.push(h)
20
}
21
+ console.log(intervals)
22
return res
23
24
function getHeight(intervals, cur) {
25
let preMaxHeight = 0
26
for (let i of intervals) {
- if (i.end < cur.start) continue
27
- if (i.start > cur.end) continue
+ if (i.end <= cur.start) continue
28
+ if (i.start >= cur.end) continue
29
preMaxHeight = Math.max(preMaxHeight, i.height)
30
31
cur.height += preMaxHeight
0 commit comments