• + 1 comment

    import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*;

    public class Solution {

    // Complete the beautifulDays function below.
    
    static int beautifulDays(int i, int j, int k) {
        int c=0,num;
        int revno=0;
        int temp,gn;
        for(int l=i;l<=j;l++)
        {
            num=l;
            temp=0;
            while(num!=0)
            {
                temp=num%10;
                revno=revno*10+temp;
                num=num/10;
            }
            gn=Math.abs(l-revno);
            if(gn%k == 0)
            {
                c++;
            }
    
        } return c;
    
        }
    
    private static final Scanner scanner = new Scanner(System.in);
    
    public static void main(String[] args) throws IOException {
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
    
        String[] ijk = scanner.nextLine().split(" ");
    
        int i = Integer.parseInt(ijk[0]);
    
        int j = Integer.parseInt(ijk[1]);
    
        int k = Integer.parseInt(ijk[2]);
    
        int result = beautifulDays(i, j, k);
    
        bufferedWriter.write(String.valueOf(result));
        bufferedWriter.newLine();
    
        bufferedWriter.close();
    
        scanner.close();
    }
    

    }

    (I followed the same approach then why ist showing wrong answer??)