Chewbacaa and Number Problem-------------

what is error in my code-----

import java.util.*;
public class Main
{
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int m = cin.nextInt(),count = 0,n = m;
while(n>0){
n = n /10;
count++;
}
if(m==0){
count = 1;
}
int arr[] = new int[count];
int s = arr.length -1;
while(m>0){
int d = m%10;
arr[s] = d;
m = m / 10;
s–;
}
for(int i = 0;i<arr.length;i++)
{
if(arr[i] == 0)
{ }
else if(9-arr[i]<arr[i])
{
arr[i] = 9-arr[i];
}
}
for(int s1: arr)
{
System.out.print(s1);
}
}
}

2 coorent test case , 2 run error and one wrong answer

Hi @AbhishekAhlawat1102,
In the question it is given that the number input can be of the range 10^18 but you are taking int which restricts the integer to only 10^9 .Therefore try taking input as float and then change the code accordingly to find the correct ans.

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.