my comment was 2 years ago, i think it was originally meant for someone that wasnt checking for empty first (or size>0). its fine if checking size/empty first and is well defined. again, it was 2 years ago, so i dont recall exactly at that time ;).
Why? I see on cppreference that it has been in standard since C++11. Since the solution has already tested if the result is empty, I think there won't be any undefined behavior here.
my comment was 2 years ago, i think it was originally meant for someone that wasnt checking for empty first (or size>0). its fine if checking size/empty first and is well defined. again, it was 2 years ago, so i dont recall exactly at that time ;).
Why? I see on cppreference that it has been in standard since C++11. Since the solution has already tested if the result is empty, I think there won't be any undefined behavior here.
Yes, actually we have a problem right here. Just checked and std::string does not terminates in NULL, I thought that was the case.
Yes, index is out of range and can lead to undefined behavoir. Should really be checking for i>0 and i<fight.size()-1
This comment is hidden because it contains spoiler information about the solution