We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
//check the code
int reverse_num(int num){
int temp = 0;
int neg = num < 0;
if (neg) num = -num;
while(num){
temp = (temp*10) + (num%10);
num /= 10;
}
return neg ? -temp:temp;
}
int beautifulDays(int i, int j, int k) {
int beautiful_count = 0;
for(int day=i; day <= j; day++){
if(abs(day - reverse_num(day)) % k == 0) {
beautiful_count++;
}
}
return beautiful_count;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Days at the Movies
You are viewing a single comment's thread. Return to all comments →
//check the code int reverse_num(int num){ int temp = 0; int neg = num < 0; if (neg) num = -num; while(num){ temp = (temp*10) + (num%10); num /= 10;
} return neg ? -temp:temp; }
int beautifulDays(int i, int j, int k) { int beautiful_count = 0;
}