fucking-algorithm icon indicating copy to clipboard operation
fucking-algorithm copied to clipboard

solution bug in book labuladong的page366 :: labuladong的算法小抄

Open guojms opened this issue 3 years ago • 0 comments

你好,我发现如下文章有 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

guojms avatar Sep 02 '22 15:09 guojms