In this question What I am doing is, that I am traversing the number, storing in an array and if the element is greater than 4 then I am replacing it with 9-digit except the most significant number and then computing answer with the array
My all test cases are not getting passed.
Is there any corner cases left which I am missing??
Here is my implemetation of code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int x;
cin>>x;
int a[20];
int temp;
int i=0;
while(x)
{
temp=x%10;
a[i++]=temp;
x/=10;
}
for(int j=0;j<i;j++)
{
if(a[j]>4&&j!=i-1)
{
a[j]=9-a[j];
}
}
int fact=10;
long long ans=0;
for(int j=i-1;j>=0;j--)
{
ans=fact*ans+a[j];
}
cout<<ans<<"\n";
}
