mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Repeated Math operation (#584)
Co-authored-by: Oleksii Trekhleb <trehleb@gmail.com>
This commit is contained in:
committed by
GitHub
parent
bbe0462b1c
commit
498ab10b1b
@@ -25,7 +25,7 @@ export default function bfRainTerraces(terraces) {
|
||||
if (terraceBoundaryLevel > terraces[terraceIndex]) {
|
||||
// Terrace will be able to store the water if the lowest of two left and right highest
|
||||
// terraces are still higher than the current one.
|
||||
waterAmount += Math.min(leftHighestLevel, rightHighestLevel) - terraces[terraceIndex];
|
||||
waterAmount += terraceBoundaryLevel - terraces[terraceIndex];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user