#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int m;
cin>>m;
string st,result;
st=to_string(m);
for(int i=0;i<st.length();i++)
{
int temp;
temp=st[i]-48;
if(temp>4)
{
temp=9-temp;
}
if(!temp & !st[i]) continue;
st[i]=temp+48;
}
cout<<st<<endl;
}
Why my code doesn't passes case 2 and case 4
Hey @the.shubham.sri
You’ve to check the case where first digit of the given number is 9, In that case, you don’t have to change it according to the question.