How to pass it for negative numbers

#include
#include
using namespace std;
int main() {
long long int n;
cin>>n;
if(n<0)
{
n*=-1;
}

long long int help;
help=n;
long long int digit=0;
while(help!=0)
{
    help=help/10;
    
    digit++;
}

int counter=0;
int answer=0;
int remainder=0;

while(counter!=digit-1)
{
      remainder=n%10;
      if(remainder>=5)
      {
          remainder=9-remainder;

      }
      answer+=(remainder)*(pow(10,counter));
      n=n/10;
      counter++;
      
}
if(n!=9&&n>=5)
{
    n=9-n;
}
answer+=(n)*pow(10,counter);
cout<<answer;

}

@Bhavit_Singla
hello bhavit,
pls check the constraint u will never be given any negative number.
image

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.