Sunidhi Bansal has Published 1085 Articles

Count number of subsets of a set with GCD equal to a given number in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:34:41

412 Views

Given an array ar, containing positive numbers and an array GCD[] containing gcd values.The goal is to find the number of subsets of elements of arr[] that have gcd values as given in GCD[].For ExampleInputarr[] = {10, 5, 6, 3}, GCD[] = {2, 3, 5}OutputCount of number of subsets of ... Read More

Count the number of rectangles such that ratio of sides lies in the range [a,b] in C++.

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:33:03

225 Views

Given sides of rectangles in and range variables first and last. The goal is to find the count of rectangles that have a ratio of their side’s length/breadth lying in the range [ first, last].For ExampleInputrec[] = { { 200, 210 }, { 100, 50 }, { 300, 190}, {180, ... Read More

Count the number of sub-arrays such that the average of elements present in the subarray is greater than that not present in the sub-array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:31:21

208 Views

Given an array arr[ ] of positive integers. The goal is to find the count of subarrays of arr[ ] that have an average of its elements greater than the average of the rest of the elements of arr[ ] that are not present in it.For ExampleInputarr[ ] = { ... Read More

Count the number of vowels occurring in all the substrings of given string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:29:23

468 Views

Given a string str containing English alphabets. The goal is to find the number of vowels occurring in all the substrings of str. If string is “abcde” then substrings will be “a”, “b”, “c”, “d”, “e”, “ab”, “bc”, “cd”, “de”, “abc”, “bcd”, “cde”, “abcd”, “bcde”, “abcde”. The count of vowels ... Read More

Count the number of ways to tile the floor of size n x m using 1 x m size tiles in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:27:43

1K+ Views

Given two numbers n and m representing the length and breadth of the floor of a room. The goal is to count the number of ways in which this floor can be tiled using the tiles of size 1Xm.For ExampleInputn=3 m=2OutputCount the number of ways to tile the floor of ... Read More

Count the number of ways to traverse a Matrix in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:25:32

317 Views

Given a 2D matrix with dimensions row X col. The goal is to count the number of ways one can traverse the matrix from cell 0, 0 to cell row, col using only right and down moves, i.e. first move can be 0, 0 to 0, 1 (down) or 1, ... Read More

Count the numbers that can be reduced to zero or less in a gamein C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:23:32

383 Views

Given an array of positive numbers and two integers A and B. Two players are playing a game in which they will reduce numbers in the array. Player 1 can decrease any element of the array by A and player 2 can increase any element of the array by B. ... Read More

Count the total number of squares that can be visited by Bishop in one move in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:21:47

869 Views

On a chessboard represented as 8 X 8 grid we are given the position of Bishop in form of row and column position. The goal is to find the total number of squares that Bishop can visit in one move. We know the Bishop can move in all directions (diagonally ... Read More

Count ways to reach a score using 1 and 2 with no consecutive 2s in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:20:10

230 Views

Given a score of runs. The goal is to reach that score in a way that the batsman can take either 1 or 2 runs only in a single ball. The restriction is that no 2 runs can be taken consecutively. For example, to reach the given score 6, one ... Read More

Count ways to express a number as sum of powers in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:18:20

1K+ Views

Given two numbers num and power as input. The goal is to find the ways in which num can be represented as a sum of unique natural numbers raised to the given power. If num is 10 and power is 2 then we can represent 10 as 12+32. So total ... Read More

Advertisements