Saturday, 4 Dec 2021
Category: factor

Given a positive integer N, the task is to find the height of the Factor Tree of the given integer N.Examples:Input: N = 20Output: 3Explaination: The height of the Factor Tree of 20 shown in the image below is 3. Input: N = 48Output: 5Approach: The given problem can be solved by using the steps […]

Count pair sums that are factors of the sum of the arrayGiven an array arr[] consisting of N integers, the task is to find the number of pairs, where i ≤ j, such that the sum of pairs divides the sum of array elements.Examples:Input: arr[] = {1, 2, 3, 4, 5}Output: 3Explanation:Below are the pairs […]

#include using namespace std;  int isPresent(int n, int x){        string num = to_string(n);          for (int i = 0; i < num.size();         i++) {                          if ((num[i] - '0') == x)            return i;    }    return -1;}  int removeDigit(int n, int index){        string num = to_string(n);          string ans = "";          for (int i = 0;         i < num.size(); i++) {        if (i != index)            ans += num[i];    }              if (ans == "" || (ans.size() == […]