Sunidhi Bansal has Published 1100 Articles

Count of words that are present in all the given sentences in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:23:07

169 Views

We are given multiple sentences in the form of strings. The goal is to count the number of words that exist in all of the sentences.Note − words containing all lowercase letters will be considered onlyIf sentences are −“ I am learning C language ”“ learning new things is easy ... Read More

Count pairs formed by distinct element sub-arrays in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:19:25

93 Views

We are given an array arr[] containing integer elements. The goal is to find the count of pairs that can be formed by elements of sub-arrays of arr[] such that each subarray has only distinct elements. If the array is [ 1, 2, 2, 3, 3 ] then subarrays with ... Read More

Count of triangles with total n points with m collinear in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:17:44

105 Views

We are given two variables n and m representing the number of points on a 2D plane. Out of n points, m points are collinear. The goal is to find the number of triangles that can be formed using these n points.Collinear points − The points that lie on the ... Read More

Count of total anagram substrings in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:16:14

610 Views

We are given a string str[] as input. The goal is to count the number of anagram substrings present in str[]. Two strings are anagrams of each other if they contain the same number of characters and all characters occur in both. The order of characters can be different.“abc” is ... Read More

Count of suffix increment/decrement operations to construct a given array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:14:43

104 Views

We are given a target array arr[] containing positive integers. The goal is to construct the target array arr[] using an initial array with all 0s. The operations that can be applied on a given empty array with all 0s will suffix increment/decrement operations.If we choose any index say i, ... Read More

Count of words whose i-th letter is either (i-1)-th, i-th, or (i+1)-th letter of given word in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:44:19

123 Views

We are given a string str[] as input. The goal is to count the words from str[] that have the same length as str[] and have positions of letters such that ith letter is replaced with letter at position (i1) or (i) or (i+1).For the first letter replacement will be ... Read More

Count pairs with sum as a prime number and less than n in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:41:45

262 Views

We are given a positive number n as input. The goal is to find the count of possible pairs (i, j) such that each pair has sum (i+j) which is prime and is less than n. Also i != j and i, j>=1 If n is 4 then only 1 ... Read More

Count permutations that are first decreasing then increasing in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:39:34

114 Views

We are a variable num. The goal is to find the count of permutations of numbers between [1, num] in which numbers are first decreasing then increasing. For example if num=3 then numbers are 1, 2, 3. The permutations will be [ 3, 1, 2 ] and [2, 1, 3] ... Read More

Count possible moves in the given direction in a grid in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:37:57

199 Views

We are two variables n and m representing a grid of size n x m and initial point x, y to start from.Also given pairs of steps/moves that can be taken to traverse inside the grid as moves ( (1, 1), (2, 2) ) etc. Each pair of moves represents ... Read More

Count pairs of parentheses sequences such that parentheses are balanced in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:36:10

670 Views

We are given a string containing the parentheses and the task is to calculate the count of pairs of parentheses sequences that can be formed such that the parentheses are balanced.Parentheses are said to be balanced when there are equal numbers of opening and closing brackets. The parentheses used once ... Read More

Advertisements