Prateek Jangid has Published 190 Articles

Find the Number of Unique Permutations Starting with 1 of a Binary String using C++

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 13:26:02

312 Views

In the given problem, we are given a string consisting of 0’s and 1’s; we are required to find the total number of permutations such that the string starts with 1’s. As the answer can be a vast number, so we print as a mod with 1000000007.Input : str ="10101001001" ... Read More

Find the Number of Unique Pairs in an Array using C++

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 13:04:53

995 Views

We require the appropriate knowledge to create several unique pairs in an array syntax in C++. In finding the number of unique pairs, we count all unique pairs in a given array, i.e., all possible pairs can be formed where each pair should be unique. For example −Input : array[ ... Read More

Find the Number of Triangles Formed from a Set of Points on Three Lines using C++

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 12:10:27

198 Views

We are given several points present in 3 lines now; we are required to find how many triangles these points can form, for exampleInput: m = 3, n = 4, k = 5 Output: 205 Input: m = 2, n = 2, k = 1 Output: 10We will apply ... Read More

Find the Number of Triangles After N Moves using C++

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 12:06:21

107 Views

n the article, first, we have to draw a colored triangle. We need to take an uncolored triangle and divide the triangle into four small equilaterals. Triangles with the same area and keep doing it till the nth step and find the number of equilateral triangles present in the figure.Approach ... Read More

Find the Number of Trailing Zeroes in base B Representation of N! using C++

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 11:45:49

194 Views

In this article, we will understand the problem of finding trailing zeros of a given number N in the base B representation of its factorial. For examplesInput : N = 7 Base = 2 Output : 4 Explanation : fact(7) = 5040 in base10 and 1001110110000 in base16 having 4 ... Read More

Find the Number of Trailing Zeroes in Base 16 Representation of N! using C++

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 11:31:56

125 Views

In this article, we will understand the problem of finding trailing zeros of a given number N in the base 16 representation of its factorial for exampleInput : N = 7 Output : 1 Explanation : fact(7) = 5040 in base10 and 13B0 in base16 having 1 trailing zero. ... Read More

Find the Number of Substrings of One String Present in Other using C++

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 11:19:24

279 Views

In this article, we are given two strings, and we need to find out how many substrings of the 1st string can be found in the 2nd string(the exact substring can occur multiple times). For exampleInput : string1 = “fogl”    string2 = “google” Output : 6 Explanation : substrings ... Read More

Find the Number of Substrings of a String using C++

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 11:07:14

5K+ Views

In this article, you will learn about the approaches to find the number of substrings (non-empty) that you can form in a given string.Input : string = “moon” Output : 10 Explanation: Substrings are ‘m’, ‘o’, ‘o’, ‘n’, ‘mo’, ‘oo’, ‘on’, ‘moo’, ‘oon’ and ‘moon’. Input : string = ... Read More

C++ Queries on Probability of Even or Odd Number in Given Ranges

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 10:34:14

204 Views

To find the probability of numbers’ parity, i.e., is it even or odd, and for the given ranges. For each query, we need to print p and q representing the probability by p / q, for example.Input : N = 5, arr[] = { 6, 5, 2, 1, 7 } ... Read More

C++ Queries for DFS of a Subtree in a Tree

Prateek Jangid

Prateek Jangid

Updated on 25-Nov-2021 10:30:20

244 Views

In this problem we are given a binary tree and we are required to perform dfs from a particular node in which we assume the given node as the root and perform dfs from it.In the above tree suppose we are required to perform DFS from node FIn this tutorial ... Read More

Advertisements