• + 4 comments

    int beautifulDays(int i, int j, int k) { int num,count=0,gn; int quo, newNum = 0, x = 0; for (int x = i; x <= j ; x++) { num = x; //make sure to assign this newNum = 0; //For reversing no while (num != 0) { quo = num % 10; newNum = 10 * newNum + quo; num = num / 10; } gn = abs(x- newNum); if (gn%k==0) { count++; } } return count; }

    the correct code for reversing (from above commented code)

    num=x //assignment of the temp number while(num!=0) { //code } if u dont assign a new variable(num) that leads to changing the value of for loop initiailizer (x) to 0 at end of the loop ,which makes the loop infinite.