Ad
  • Default User Avatar

    closing since it's a question, not an issue

  • Custom User Avatar

    The instructions are not that long, read them again, what you should return is there, how can you pass that? Besides,you have sample tests to see what your function should return. People should read better.

  • Default User Avatar

    Thank you. I totally forgot it returns unsigned

  • Custom User Avatar

    I was having the same problem, it turned out to be when the vector is empty and we subtract 1 from its size, the comparison in the for loop doesn't work as we expect because v.size() returns an unsigned, and the result of 0 - 1 ends up beign a big positive number instead of -1

    Oh man, I love c++ hahah