Ad
  • Custom User Avatar

    The check for size == 0 is redundant. If the size is zero std::accumulate returns 0 anyway.
    I think returning -1 isn't a good practice anymore. In general use std::optional for that.
    In this case returning -1 is simply wrong! the sum of an empty vector just isn't -1, also suppose the vector was { 1, 1, -3 } then it's sum would also be -1.

  • Custom User Avatar

    A const is more or less just an int that represents an ascii value.
    7097511 takes advantage of that by defining a new alphabet and then getting the corresponding letters.