0

Youtube Link Finder Code Coach https://www.sololearn.com/coach/74?ref=app

#include <iostream> #include <string.h> #include <algorithm> using namespace std; int main() { string a,ans; cin>>a; ans+='\0'; for (int i=a.length();i>=0;i--) { if (a[i] == '=') break; else if (a[i] == '/' && a[i-1] == 'e') break; ans+=a[i]; } reverse(ans.begin(),ans.end()); cout<<ans; return 0; } This is my code, I am getting the output correctly but my test cases are failing. Can someone help ?

21st May 2021, 1:34 PM
Pratham Vasani
Pratham Vasani - avatar
1 Odpowiedź
+ 2
you don't need null character just make ans = "" //before loop. make loop condition look like : for (int i=a.length()-1;i>0;i--) //added -1 and removed =
21st May 2021, 4:48 PM
Bahhaⵣ
Bahhaⵣ - avatar