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