Hafeezul Kareem has Published 328 Articles

Number of digits in the nth number made of given four digits in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 26-Oct-2021 07:00:47

189 Views

We need to find the number of digits in the nth number made of given four digits 1, 2, 3, and 4.The series with the above four digits is as follows1, 2, 3, 4, 11, 12, 13, 14, 21, 22, 23, 24...We need to find the number of digits of ... Read More

Number of Digits in a^b in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 26-Oct-2021 06:53:53

166 Views

The power of a number can be computed using the iterative multiplication or function that the language provides. It's a straightforward thing.Here, we have to find the a raised to power b. And the number of digits in the result. Let's see some examples.Inputa = 5 b = 2Output2 Inputa ... Read More

Number of digits in 2 raised to power n in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 26-Oct-2021 06:38:43

136 Views

The power of a number can be computed using the iterative multiplication or function that the language provides. It's a straightforward thing.Here, we have to find the 2 raised to power n. And the number of digits in the result. Let's see some examples.Input5Output2Input10Output4 AlgorithmInitialise the number n.Find the value ... Read More

Number of arrays of size N whose elements are positive integers and sum is K in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 26-Oct-2021 06:33:42

381 Views

We are given two numbers n and k. We need to find the count of arrays that can be formed using the n numbers whose sum is k.The number of arrays of size N with sum K is $\dbinom{k - 1}{n - 1}$.This a straightforward formula to find the number ... Read More

Number of anomalies in an array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 26-Oct-2021 06:03:10

233 Views

In this tutorial, we are going to write a program that finds the number of anomalies in the given array.A number is an anomaly in the given array if the absolute difference between the number and all other numbers is greater than the given number k. Let's see an example.Inputarr ... Read More

Number is divisible by 29 or not in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 26-Oct-2021 06:00:45

130 Views

It's a straightforward problem. We can use the modulo (%) operator to check whether the given number is divisible by 29 or not. Let's see some examples.Input29 254Output1 0AlgorithmImplementationFollowing is the implementation of the above algorithm in C++#include using namespace std; bool isDivisibleBy29(long long n) {    return n ... Read More

Multiply two polynomials in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 26-Oct-2021 05:56:45

4K+ Views

The coefficients of each term of the polynomial are given in an array. We need to multiply the two polynomials. Let's see an example.InputA = [1, 2, 3, 4] B = [4, 3, 2, 1]Output4x6 + 11x5 + 20x4 + 30x3 + 20x2 + 11x1 + 4AlgorithmInitialise two polynomials.Create a ... Read More

Multiply two numbers represented as linked lists into a third list in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 17:04:14

271 Views

Given two linked lists with digits in it. We need to multiply two numbers formed by the linked list. It can be done easily by forming the numbers from the two linked lists. Let's see an example.Input1 -> 2 -> NULL 2 -> 3 -> NULLOutput2 -> 7 -> 6 ... Read More

Multiply two numbers represented by Linked Lists in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 16:28:34

1K+ Views

Given two linked lists with digits in it. We need to multiply two numbers formed by the linked list. It can be done easily by forming the numbers from the two linked lists. Let's see an example.Input1 -> 2 -> NULL 2 -> 3 -> NULLOutput2 -> 7 -> 6 ... Read More

Multiply Large Numbers represented as Strings in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 07:10:44

4K+ Views

Given two numbers in the string formats. We need to multiply them. The idea to solve the problem is to maintain a previous digit multiplication answer and carry. We can use the previous digits multiplication answer and carry to get the next set digits multiplication.Let's see an example.Input15 2Output30AlgorithmInitialise the ... Read More

Advertisements