Extra-terrestrials Help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Extra-terrestrials Help

I need help with the extra-terrestrials challenge. I'm able to reverse the string, but all my test cases fail. Am I missing something? https://code.sololearn.com/cTUQK8TC4DkZ/?ref=app

27th Jun 2020, 6:59 PM
♡Addy♡
♡Addy♡ - avatar
3 Answers
+ 6
change to int i = userInput.size()-1;
27th Jun 2020, 7:18 PM
Reivin
Reivin - avatar
+ 4
Reivin Dedstinguer Ahhh, Thank you. I'm an idiot lol
27th Jun 2020, 7:21 PM
♡Addy♡
♡Addy♡ - avatar
+ 3
FYI, there is a reverse function in the Non-standard header; #include <bits/stdc++.h> And similarly in the header; #include <algorithm> Either, does an in place reversal of the string by passing in the begin and end iterators of the object. reverse(userInput.begin(), userInput.end()); cout << userInput; http://cplusplus.com/reference/algorithm/reverse/
27th Jun 2020, 11:45 PM
ChaoticDawg
ChaoticDawg - avatar