Chewbacca an integer number

1 test case getting failed, can;t figure out why?
hers’s the code;
#include<bits/stdc++.h>

using namespace std;

int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n;
cin>>n;
long long int temp=n;
vector k;
while(n>0)
{

  long long int x=n%10;
  if(x>4 and n/10>0)
  x=9-x;
  k.push_back(x);
  n/=10;

}
reverse(k.begin(),k.end());
for(long long int i=0;i<k.size();i++)
cout<<k[i];

return 0;

}

hey @rockstarpkm you are always ignoring the first number but you should only ignore first number when it is equals to 9 or less than 4, for example in case of 81 answer should be 11 but your answer is 81.

1 Like