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.
int reverse(int n){
int rev=0;
int rem=0;
while (n!=0){
rem=n%10;
rev=rev*10+rem;
n/=10;
}
cout<< rev<< endl;
return rev;
}
// Complete the beautifulDays function below.
int beautifulDays(int i, int j, int k) {
int ctr=0;
for (int x =i;x<=j;x++){
int rev=reverse(x);
if (abs(rev-x)%k==0){
ctr+=1;
}
}
return ctr;
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 →
int reverse(int n){ int rev=0; int rem=0; while (n!=0){ rem=n%10; rev=rev*10+rem; n/=10; } cout<< rev<< endl; return rev; } // Complete the beautifulDays function below. int beautifulDays(int i, int j, int k) { int ctr=0; for (int x =i;x<=j;x++){