Sunidhi Bansal has Published 1085 Articles

Count Substrings with equal number of 0s, 1s and 2s in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:07:16

403 Views

We are given string str containing 0’s, 1’s, and 2’s only. The goal is to find all substrings of str that have equal numbers of 0’s 1’s and 2’s. If str is “12012”. Substrings with equal 0’s, 1’s, and 2’s will be “120”, “201” and “012”. The count will be ... Read More

Count occurrences of a string that can be constructed from another given string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:05:26

220 Views

We are given with two strings str_1 and str_2 as input. The goal is to find the count of strings same as str_2 that can be constructed using letters picked from str_1 from which each character is used just once.Note − All alphabets in both are in the same case.Let ... Read More

Count Numbers with N digits which consists of odd number of 0's in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:04:40

311 Views

We are given a number N as input. The goal is to find all N digit numbers that have an odd number of 0’s as digits. The number also could have preceding zeros like in case of N=3 numbers included will be 000, 011, 012….990.Let us understand with examples.Input − ... Read More

Count Numbers with N digits which consists of even number of 0's in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:02:25

183 Views

We are given a number N as input. The goal is to find all N digit numbers that have an even number of 0’s as digits. The number also could have preceding zeros like in case of N=3 numbers included will be 001, 002, 003….010….so on.Let us understand with examples.Input ... Read More

Count number of pairs (A <= N, B <= N) such that gcd (A , B) is B in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:01:08

690 Views

We are given an input N. The goal is to find all pairs of A, B such that 1

Count the pairs of vowels in the given string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2020 06:20:11

364 Views

We are given with a string of characters and the task is to calculate the count of pairs having both the elements as vowels. As we know there are five vowels in English alphabet i.e. a, i, e, o, u and other characters are known as Consonants.Input − string str ... Read More

Count the number of elements in an array which are divisible by k in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2020 06:18:19

1K+ Views

We are given with an array of positive integer numbers and an integer variable k. The task is to calculate the count of the number of elements in an array which is divisible by the given value k.Input − int arr[] = {4, 2, 6, 1, 3, 8, 10, 9}, ... Read More

Count of character pairs at same distance as in English alphabets in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2020 06:16:00

169 Views

We are given a string of characters and the task is to calculate the count of character pairs having pairs at the same distance as we have in english alphabets.Input − string str = ‘Tutorials Point’Output − Count of character pairs at same distance as in English alphabets are: 5Explanation ... Read More

Count of numbers having only 1 set bit in the range [0, n] in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2020 06:14:40

257 Views

We are given a number and the task is to calculate the count of numbers from the range 0 till the given number let’s say, num having exactly one set bitSet bits in a binary number is represented by 1. Whenever we calculate the binary number of an integer value ... Read More

Count of matrices (of different orders) with given number of elements in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2020 06:12:30

265 Views

We are given the total number of elements and the task is to calculate the total number of matrices with different orders that can be formed with the given data. A matrix has an order mxn where m are the number of rows and n are the number of columns.Input ... Read More

Advertisements