Please can somebody tell the error
logic is i have first stored the number in an array
then applied the conditions given in the question the reason two arrays are involved because the first stored array was inverted as stored the numbers in reverse order.
What's t wrong only one test case failing
Instead of the approach you are using, try to use this simple approach as :
string str;
cin>>str;
int i=0;
if(str[i]==‘9’)
{
i++;
}
for(;str[i]!=’\0’;i++)
{
int digit = 9-str[i]+‘0’;
if(digit<5)
{
str[i]=digit+‘0’;
}
}
cout<<str;