It is showing time limit exceeded error

#include
using namespace std;
int rem=0,sum=0;
int replace(int n){

while(n!=0){
rem=n%10;
n=n/10;
if(rem==0){
sum=sum*10+5;
}
else{
sum=sum*10+rem;
}
}

return sum;
}

int invertback(int n){
while(n!=0){
int k=sum%10;
sum=sum/10;
sum=sum*10+k;
}
cout<<sum;
return sum;
}
int main(){
int n;
cin>>n;
replace(n);
cout<<invertback(n);
}

https://online.codingblocks.com/app/player/246132/content/235737/4714/code-challenge

hi @sbhardwaj1be21_2a991b329433c059, please share the code link on ide.codingblocks.com

hi @sbhardwaj1be21_2a991b329433c059 save ur code i see a blank page

sorry for the inconvenience.

hi @sbhardwaj1be21_2a991b329433c059 updated https://ide.codingblocks.com/s/667539

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like