Sort by

recency

|

1760 Discussions

|

  • + 0 comments

    def beautifulDays(i, j, k): count=0 for day in range(i,j+1): d1=str(day) d2=d1[::-1] dif=abs(int(d1)-int(d2))%k==0 if dif: count += 1 return count # Write your

  • + 0 comments

    Much more optimal solution in java : `

    import java.util.Scanner;

    public class BeautifulDaysAtTheMovies {

    public static int beautifulDays(int i, int j, int k) {
        int count = 0;
    
        for (int day = i; day <= j; day++) {
            int reversed = reverseNumber(day);
            if (Math.abs(day - reversed) % k == 0) {
                count++;
            }
        }
    
        return count;
    }
    
    private static int reverseNumber(int num) {
        int reversed = 0;
        while (num > 0) {
            reversed = reversed * 10 + num % 10;
            num /= 10;
        }
        return reversed;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
    
        // Read input values
        int i = scanner.nextInt();
        int j = scanner.nextInt();
        int k = scanner.nextInt();
    
        // Compute and print the number of beautiful days
        System.out.println(beautifulDays(i, j, k));
    
        scanner.close();
    }
    

    } `

  • + 0 comments

    Here my java solution

    public static int beautifulDays(int i, int j, int k) { int count = 0;

    for (int m = i; m <= j; m++) {
        int n = m;
        int reversed = 0;
    
        while (n != 0) {
            reversed = reversed * 10 + n % 10;
            n /= 10;
        }
    
        if (Math.abs(m - reversed) % k == 0) {
            count++;
        }
    }
    
    return count;
    

    }

  • + 0 comments

    Cinegato sounds like an exciting platform for movies and films! If it helps filmmakers, producers, or movie enthusiasts discover, create, or stream content, it could be a game-changer in the industry. Whether cinegato offers reviews, recommendations, or filmmaking tools, it is always great to have innovative solutions in the entertainment space. Would love to know more about how it works and what makes it stand out from other platforms.

  • + 0 comments

    Cinegato sounds like an exciting platform for movies and films! If it helps filmmakers, producers, or movie enthusiasts discover, create, or stream content, it could be a game-changer in the industry. Whether cinegato offers reviews, recommendations, or filmmaking tools, it is always great to have innovative solutions in the entertainment space. Would love to know more about how it works and what makes it stand out from other platforms.