Sunidhi Bansal has Published 1100 Articles

Count squares with odd side length in Chessboard in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:33:58

755 Views

Given a number size as input as dimension of size*size Chessboard. The goal is to find the number of squares that can be formed inside that board having odd lengths.For ExampleInputsize=3OutputCount of squares with odd side length in Chessboard are: 10ExplanationAll squares will be as shown : and 1 whole ... Read More

Count subsets that satisfy the given condition in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:32:05

295 Views

Given an array of numbers and an integer x as input. The goal is to find all the subsets of arr[] such that individual elements of that set as well as the sum of them fully divisible by x.For ExampleInputarr[] = {1, 2, 3, 4, 5, 6} x=3OutputCount of subsets ... Read More

Count the number of common divisors of the given strings in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:30:22

185 Views

Given two strings numo and demo as input. The goal is to find the number of common divisors of both the strings. The divisors of a string are found using following technique: If string str has sub1 as its divisor then we can construct str using sub1 by repeating it ... Read More

Count number of trees in a forest in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:27:47

353 Views

Given vertices of a forest ( collection of trees). The goal is to find the number of trees in that forest. We will do this by running a DFS (depth first search) algorithm on the forest.For ExampleInputedges = { { 1, 3 }, {2, 8}, {2, 6}, {3, 5}, {3, ... Read More

Construct sum-array with sum of elements in given range in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 07:30:09

456 Views

Given an array arr[ ] containing integers only and an odd number sum. The goal is to create a sum array arr_2[ ] such each arr_2[i] is the sum of previous sum/2 elements of arr[] + arr[i] + next sum/2 elements of arr[]. If sum is 1 then arr_2[i]=arr[i]For ExampleInputarr[] ... Read More

Count the number of currency notes needed in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 07:28:24

437 Views

Given an amount in rupees that one has to pay, say pay_rupees and an unlimited amount of banknotes that have value as Rupees_amount_1 and Rupees_amount_2. The goal is to pay pay_rupees using exactly the total number of notes=distribution_total and count the number of type Rupees_amount_1 notes required. If there is ... Read More

Count number of strings (made of R, G and B) using given combination in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 07:26:32

275 Views

Given three numbers R, G and B and letters ‘R’, ‘G’ and ‘B’ only. The goal is to find the count of possible strings that can be made using at least R Rs, at least G Gs and at least B Bs in it. The numbers R, G and B ... Read More

Count number of subsets having a particular XOR value in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 07:25:01

307 Views

Given an array arr[ ] containing positive integers and a value match. The goal is to find the subsets of arr[] that contain elements that have XOR = match.For ExampleInputarr[] = {4, 2, 8, 10} match=12OutputCount of number of subsets having a particular XOR value are: 2ExplanationSubsets of arr with ... Read More

Count the number of non-increasing subarrays in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 07:20:43

253 Views

Given an array arr[] containing positive integers. The goal is to find the number of subarrays of length at least 1 which are non−increasing. If arr[]= {1, 3, 2}, then subarrays will be {1}, {2}, {3}, {3, 2}. Count is 4.For ExampleInputarr[] = {5, 4, 5}OutputCount of number of non-increasing ... Read More

Count the number of holes in an integer in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 07:19:18

411 Views

Given an array of holes[10] containing a number of holes in numbers 0 to 9. The goal is to find the number of holes in an integer number given as input. Given − holes[] = { 2, 1, 1, 0, 0, 1, 1, 1, 0 }For ExampleInputnumber = 239143OutputCount the ... Read More

Advertisements