## Multiples of 3 and 5 without using % operator in C++ Hafeezul Kareem

Updated on 27-Oct-2021 06:28:22

We can find the multiples using % operator without any hurdles. But, the problem states that we can't use % operator.Here, we make use of the + operator. We can get the multiples by adding 3 or 5 to the previous multiple. Let's see an example.Input15Output1 2 3 - Multiple ... Read More

## Nearest 1 in a binary matrix in C++ Hafeezul Kareem

Updated on 27-Oct-2021 05:34:37

Given a binary matrix, we need to find the minimum distance from each cell to the nearest cell that contains 1.Let's see an example.Input0 0 1 1 1 0 0 0 0Output1 1 0 0 0 1 1 1 2The minimum distance is the one that is minimum from current ... Read More

## Number of pairs with maximum sum in C++ Hafeezul Kareem

Updated on 26-Oct-2021 19:25:03

Given an array, we need to find the number of pairs with maximum sum. Let's see an example.Inputarr = [3, 6, 5, 2, 1, 2, 3, 4, 1, 5]Output2 The maximum pair sum is 10. There are 2 pairs with maximum sum. They are (5, 5) and (6, 4).AlgorithmInitialise the ... Read More

## Number of pairs with Bitwise OR as Odd number in C++ Hafeezul Kareem

Updated on 26-Oct-2021 19:18:54

Given an array, we have to find the number of pairs whose Bitwise OR is an odd number. Let's see the example.Inputarr = [1, 2]Output1 There is only one pair whose Bitwise OR is an odd number. And the pair is (1, 2).AlgorithmInitialise the array with random numbers.Initialise the count ... Read More

## Number of pairs whose sum is a power of 2 in C++ Hafeezul Kareem

Updated on 26-Oct-2021 19:09:44

Given an array, we have to find the number of pairs whose sum is a power of 2. Let's see the example.Inputarr = [1, 2, 3]Output1 There is only one pair whose sum is a power of 2. And the pair is (1, 3).AlgorithmInitialise array with random numbers.Initialise the count ... Read More

## Number of pairs from the first N natural numbers whose sum is divisible by K in C++ Hafeezul Kareem

Updated on 26-Oct-2021 18:56:50

Given numbers N and K, we have to count the number of pairs whose sum is divisible by K. Let's see an example.InputN = 3 K = 2Output1 There is only one pair whose sum is divisible by K. And the pair is (1, 3).AlgorithmInitialise the N and K.Generate the ... Read More

## Number of ordered points pair satisfying line equation in C++ Hafeezul Kareem

Updated on 26-Oct-2021 18:42:03

The line equation that should be satisfied is y = mx + c. Given an array, m, and c, we have to find the number of order points satisfying the line equation. Let's see an example.Inputarr = [1, 2, 3] m = 1 c = 1Output2The pairs satisfying the line ... Read More

## Number of non-negative integral solutions of sum equation in C++ Hafeezul Kareem

Updated on 26-Oct-2021 18:32:38

In this tutorial, we are going to write a program that finds the number non-negative integral solution of sum equation.The sum equation is x + y + z = n. You are given the number n, you need to find the number of solutions for the equation. Let's see an ... Read More

## Number of nodes greater than a given value in n-ary tree in C++ Hafeezul Kareem

Updated on 26-Oct-2021 18:25:17

Given an n-ary tree and a number, we have to count the number of nodes greater than the given number. Let's see an example.Inputtree = [, [1, 2], [3, 5]] n = 2Output3There are 3 nodes with values that are greater than n.AlgorithmInitialise the n-ary tree.Initialise the count to 0.Increment ... Read More

## Number of NGEs to the right in C++ Hafeezul Kareem

Updated on 26-Oct-2021 15:27:07

You are given an array and the index of the target element. We have to count the number of elements greater than the given element to its right. Let's see an example.Inputarr = [2, 3, 5, 1, 4, 2, 6] index = 3Output3The target index element is 1. There are ... Read More

1 2 3 4 5 ... 38 Next