Chewbacca and number

Sir 2 of my testcases are getting failed.
#include
using namespace std;

int main()
{
int n;
cin>>n;
int arr[1000];
int i=0;
while(n>0){
int dig=n%10;
int inv_dig=9-dig;
if(inv_dig<dig){
dig=inv_dig;
}
arr[i]=dig;
i++;
n=n/10;
}
int no=i-1;
if (arr[no]==0){
arr[no]=1;
}
for(int j=i-1;j>=0;j–){

    cout<<arr[j];
}
return 0;

}

Mistakes:

  1. increase the size of int variable as “long long int” because the constraints requires higher value as :

image

  1. if the starting digit is 9 then don’t make it zero

Your Modified Code is: