Hafeezul Kareem has Published 344 Articles

Finding ‘k’ such that its modulus with each array element is same in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:58:00

295 Views

In this tutorial, we are going to write a program that finds a number such that its modulus with each array element is same. Let's see an example.Input − arr = {10, 4, 2}Output − 1 2If there are two numbers x, y and x > y, assume that x ... Read More

Find ΔX which is added to numerator and denominator both of fraction (a/b) to convert it to another fraction (c/d) in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:55:18

64 Views

In this tutorial, we are going to write a program that calculates ∆ X value that satisfies the given equation. The equation is (a + ∆ X)/(b + ∆ X) = c/d.Here, we need a little bit of math to solve the equation. And it's straightforward. Cross multiply and take ... Read More

Find zeroes to be flipped so that number of consecutive 1’s is maximized in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:51:19

58 Views

In this tutorial, we are going to find the zeroes count that need to be flipped to get maximum number of consecutive 1's in the array.We are going to use the sliding window approach to solve the problem. Let's see the steps to solve the problem.Initialize the array and max ... Read More

Find winner of an election where votes are represented as candidate names in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:49:34

628 Views

In this tutorial, we are going to write a program that finds the election winner. We will have an array of votes that each candidate got in the election. Let's see an example.Input {"A", "B", "C", "B", "A", "C", "D", "D", "A", "B", "D", "B", "A", "C", "D"}Output AHere, A and B ... Read More

Find ways an Integer can be expressed as sum of n-th power of unique natural numbers in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:47:42

403 Views

In this tutorial, we are going to write a program that find the number of ways a integer can be expressed as sum of given n-th power of unique numbers.We have two integers number and power. And we need to find in how many ways can we represent the given ... Read More

Find unique pairs such that each element is less than or equal to N in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:43:17

87 Views

In this tutorial, we are going to learn how to find the unique pairs that are less than the given number n.Let's see the steps to solve the problem.Initialize the number.Iterate from i = 1 to i < n.Iterate from j = i + 1 to j < n.Print the ... Read More

Find Union and Intersection of two unsorted arrays in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:42:05

575 Views

In this tutorial, we are going to learn how to write a program for union and intersection of two unsorted arrays. Let's see an example.Input arr_one = [1, 2, 3, 4, 5] arr_two = [3, 4, 5, 6, 7]Output union: 1 2 3 4 5 6 7 intersection: 3 4 5Let's see ... Read More

Find uncommon characters of the two strings in C++ Program

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:40:04

403 Views

In this tutorial, we are going to learn how to find distinct characters from the given two strings. Let's see an example.Input string_one = "tutorialspoint" string_two = "tutorialsworld"Outputd n p wWe are going to use hashing to solve the problem. It's more efficient than writing two nested loopLet's see the steps ... Read More

Find two numbers with sum and product both same as N in C++ Program

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:38:11

180 Views

In this tutorial, we are going to write a program to find two numbers where x + y = n and x * y = n. Sometimes it's not possible to find those types of numbers. We'll print None if there are no such numbers. Let's get started.The given numbers are ... Read More

Find two distinct prime numbers with given product in C++ Program

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:36:16

279 Views

In this tutorial, we are going to write a program the find two distinct prime numbers with the given product. Let's see some examples.Input − 21Output − 3 7Here, we need to have all the prime numbers that are less than the given product. Once we have those prime numbers, ... Read More

Advertisements