fucking-algorithm
fucking-algorithm copied to clipboard
solution bug in book labuladong的page366 :: labuladong的算法小抄
你好,我发现如下文章有 bug(点击文字可跳转到相关文章):
labuladong的算法小抄page366
问题描述:
in this bruce force solution,
line: ans+= min(l_max, r_max) - height[i] could be negative
it should ignore when it's negative like example with index 1
l_max = 0, l_right =3, ans +=min(0,3) - 1, it returns -1
add if condition or tempAns = tempAns ? tempAns: 0