• + 0 comments

    Simple Java Solution

    class Result {
    
        /*
         * Complete the 'beautifulDays' function below.
         *
         * The function is expected to return an INTEGER.
         * The function accepts following parameters:
         *  1. INTEGER i
         *  2. INTEGER j
         *  3. INTEGER k
         */
        
        public static int beautifulDays(int i, int j, int k) {
        // Write your code here
        int total = 0;
        for(;i<=j; i++)
        {
            int temp = i;
            int rev = 0;
    				
            while(temp != 0)
            {
                int lst = temp%10;
                temp = temp / 10;
                rev = rev * 10 + lst;
            }
            int diff = Math.abs(i - rev);
            if(diff % k == 0)
            {
                total++;
            }
        }
        return total;
        }
    
    }