+ 2

What's wrong/ youtube find linker

The last of the 5 test cases (which is hidden) gives error and I don't know what the failure is, all the other cases I passed, what could it be? include <iostream> using namespace std; int main() { char you[50]; int x; char most[50]; cin>>you; bool conf; for(int i=0; i<50; i++ ){ if(you[i]=='='){ conf=true;continue; } if(conf==1){most[x]=you[i];x++;} } if(conf==0){ for(int j=0; j<50; j++ ){ if(you[j]=='e'){ conf=true;j++;continue;} if(conf==1){most[x]=you[j];x++;} } cout<<most; } else cout<<most; return 0; }

28th Jan 2021, 7:55 AM
Julio Amaro
Julio Amaro - avatar
2 Answers
+ 4
You are right. With your code , the last hidden test case is occurring false . I don't know what is wrong with above code. But , there is another hack for solving that YouTube link founder problem . The output for every test cases is of only 11 characters, so by subtracting 11 from the length of string and starting the loop from that substraction to the length of string, you will get your answer. #include <iostream> using namespace std; int main() { string a; int n,s; cin>>a; n=a.length(); s=n-11; for(int i=s;i<n;i++) cout<<a[i]; return 0; }
28th Jan 2021, 9:04 AM
Hrutik Bhalerao
Hrutik Bhalerao - avatar
+ 2
Thank you so much, I see it's easier
28th Jan 2021, 9:18 AM
Julio Amaro
Julio Amaro - avatar