+ 1
YouTube links challenge not accepting correct answer?
I tried to solve the YouTube links challenge with cpp. My code seemed to have given the correct output but it wasn't accepted as correct. This is the code: '''cpp #include <iostream> #include <algorithm> using namespace std; int main() { string url; string result; cin >> url; for (size_t i=url.size();i>0;i--) { if (url[i]=='='||url[i]=='/') { break; } result += url[i]; } reverse(result.begin(), result.end()); cout <<result; return 0; } '''
4 Answers
+ 3
Do any of the test cases pass? Does it fail on any of the test cases?
+ 2
Alejandra Camus the problem is that your output includes the non-printable terminating null from the end of the input string. HINT: Check your loop limits.
+ 2
Brian , good catch. Solved!
+ 1
The first 2 test cases (the only ones unlocked) fail, even though the output of the test cases seems to be exactly the output of my program in both test cases