Sunday, 28 Nov 2021
Category: number-digits

Given a positive integer N, the task is to check whether all the digits of the given integer N are the same or not. If found to be true, then print Yes. Otherwise, print No.Examples:Input: N = 222Output: YesInput: N = 232Output: NoNaive Approach: The simplest approach to solve the given problem is to iterate […]

import java.util.*;  class GFG{static int dp[][][] = new int[100][10][10];static int countOfNumbers(int digit, int prev1,                   int prev2, int n){            if (digit == n + 1) {        return 1;    }            int val = dp[digit][prev1][prev2];    if (val != -1) {        return val;    }    val = 0;                    if (digit == 1) {        for (int i = (n == 1 ? 0 : 1); i

Check if sum of digits in the left half is divisible by sum of digits in the right half in the largest permutation of NGiven a positive integer N, the task is to maximize the integer N by rearranging the digits and check if the sum of the left half digits is divisible by the […]