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.
// Complete the beautifulDays function below.
static int beautifulDays(int i, int j, int k) {
int c=0,num;
int revno=0;
int temp,gn;
for(int l=i;l<=j;l++)
{
num=l;
temp=0;
while(num!=0)
{
temp=num%10;
revno=revno*10+temp;
num=num/10;
}
gn=Math.abs(l-revno);
if(gn%k == 0)
{
c++;
}
} return c;
}
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
String[] ijk = scanner.nextLine().split(" ");
int i = Integer.parseInt(ijk[0]);
int j = Integer.parseInt(ijk[1]);
int k = Integer.parseInt(ijk[2]);
int result = beautifulDays(i, j, k);
bufferedWriter.write(String.valueOf(result));
bufferedWriter.newLine();
bufferedWriter.close();
scanner.close();
}
}
(I followed the same approach then why ist showing wrong answer??)
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 →
import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*;
public class Solution {
}
(I followed the same approach then why ist showing wrong answer??)