Ad
  • Default User Avatar

    Thanks!

  • Default User Avatar

    Ahh now I get it. The towers are blocking it against their neighbours. I understood something like they are water towers of a given capacity or such things. Boing. Yea, makes sense now. Thank you!

  • Custom User Avatar

    Let's take the first 2 examples in description:

    [5,2,10] should return 3

    So if it rains, there will be 3 units of water between 5 and 10 (it will become [5, 5, 10] (any more would just fall to left side, or right side of 10, which we don't care about)

    [1,0,5,2,6,3,10] should return 7

    So there is space for 1 unit between 1 and 5, 3 units between 5 and 6, and 3 more units between 6 and 10, ending in state [1, 1, 5, 5, 6, 6, 10] (1 + 3 + 3 = 7)

    Does that make any sense?

  • Default User Avatar

    Am I the only one who doesn't understand what to do?
    How do I calculate this? (No code needed, I just don't get what do to)

  • Default User Avatar

    Uh, these special edge cases were killing it for me.
    Still thanks for the training!

  • Default User Avatar

    Yea these edge cases of empty arrays came a little surprising. Not sure if I missed that in the description but it was a bit annoying.
    Still, thanks for the task!

  • Default User Avatar

    String concatenation is pretty slow (since Strings are immutable). For a bigger task use a StringBuilder or StringBuffer instead.

  • Default User Avatar

    instead of 1..number-1 you can use 1 until number. The until excludes the end. Might make code more readable!