-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeautifulDays.cpp
More file actions
25 lines (23 loc) · 824 Bytes
/
Copy pathBeautifulDays.cpp
File metadata and controls
25 lines (23 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* https://www.hackerrank.com/challenges/beautiful-days-at-the-movies/problem */
/* Simply replace the given function with the function below*/
int beautifulDays(int i, int j, int k) {
int total_beautiful_days = 0;
for(int d = i; d <= j; d++)
{
int num = d, quotient = 0, reverse = 0;
// reverse the number
while (num != 0)
{
quotient = num % 10;
// cout << quotient << " is quotient ";
// cout << reverse << " is reverse before ";
reverse = 10 * reverse + quotient;
// cout << reverse << " is reverse after ";
num = num / 10;
// cout << num << " is num " << endl << endl;
}
if((reverse - d) % k == 0)
total_beautiful_days++;
}
return total_beautiful_days;
}