• + 0 comments

    Here is my c# solution, i didnt use array to reverse

        public static int beautifulDays(int i, int j, int k)
        {
            int reverse = 0,day = 0;
            for(int num=i ; num <= j ; num++){
                int temp = num;
                while(temp > 0){
                    reverse = reverse * 10 + temp % 10;
                    temp /= 10;
                }
                int diff = Math.Abs(num - reverse);
                if(diff%k == 0){
                    day++;
                }
                reverse = 0;
            }
            return day;
        }