C++ Articles

Page 41 of 597

Count of alphabets whose ASCII values can be formed with the digits of N in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 327 Views

Given a long variable containing a positive number as input. The goal is to find the count of alphabets whose ASCII value digits are present in the digits of the number.Pick any two digits from the number and arrange them in a manner such that they form an ASCII value of English alphabets. ASCII values of A-Z start from 65 to 90 and ASCII values of a-z start from 97 to 122.Total numbers that are to be picked will be 26+26=52.Let us understand with examples.For ExampleInput -  N_digits = 163465Output - Count of alphabets whose ASCII values can be formed with ...

Read More

Count of cells in a matrix which give a Fibonacci number when the count of adjacent cells is added in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 193 Views

Given a matrix [ ][ ] having dimensions as row x col. The goal is to find the count of cells of matrix that meet the given condition:Value of cell matrix [i][j] + no. of adjacent cells to it = a Fibonacci numberNumbers in Fibonacci series:- 0, 1, 1, 2, 3, 5, 8, 13, 21, 43 …..Let us understand with examples.For ExampleInput - matrix[row][col] = {{1, 4, 1}, {2, 0, 1}, {5, 1, 1}Output - Count of cells in a matrix which give a Fibonacci number when the count of adjacent cells is added are: 4Explanation      0    1 ...

Read More

Count of n digit numbers whose sum of digits equals to given sum in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 476 Views

Given a positive number as the number of digits and a sum. The goal is to find all d digit numbers that have sum of digits equal to the input sum. The numbers having leading zeros will not be considered as d digit numbers.The ranges are digits between 1 to 100 and sum between 1 and 500.Let us understand with examples.For ExampleInput - digits = 3, digi_sum = 3Output - Count of n digit numbers whose sum of digits equals to given sum are: 6Explanation - Three digit numbers having sum of digits as 3 are:102, 111, 120, 201, 210, ...

Read More

Count of Numbers in Range where first digit is equal to last digit of the number in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 567 Views

Given a range of numbers between start and end. The goal is to find the count of numbers that have the first digit equal to the last digit and fall in the range [ first, last ].All single digit numbers will be counted if they lie in the range.Let us understand with examples.For ExampleInput - start = 100, end = 200Output - Count of Numbers in Range where first digit is equal to last digit of the number are: 10Explanation -  The numbers will be:101, 121, 131, 141, 151, 161, 171, 181 and 191.Input - start = 1, end = ...

Read More

Count sub-matrices having sum divisible 'k' in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 347 Views

Given a row x col matrix as input. The goal is to find all submatrices within the matrix[row][col] such that the sum of elements of that submatrix is divisible by integer k.If the matrix is mat[3][3] and k is 4 then submatrices will be as shown below:- Let us understand with examples.For ExampleInput - matrix[3][3] = { {1, 1, 1}, {2, 2, 2}, {3, 3, 3} }    k=4Output - Count of sub-matrices having sum divisible 'k' are: 4Explanation -  The submatrices will be as shown in above.Input - matrix[3][3] = { {1, 1, 1}, {2, 2, 2 }, {3, 3, ...

Read More

Count of numbers satisfying m + sum(m) + sum(sum(m)) = N in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 266 Views

Given a number N as input. The goal is to find numbers m upto N that satisfy the following condition. Here N

Read More

Count the number of nodes at given level in a tree using BFS in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 1K+ Views

Given an undirected graph containing the nodes of a tree as vertices. The goal is to find the count of nodes at a given level of the tree using BFS( breadth first search ) algorithm.BFS Algorithm:-This algorithm starts traversing the graph/tree level by level. Starting from node at level 0, it will first traverse all nodes directly connected to it at level 1, then will traverse all nodes at next level and so on.Traverse nodes horizontally at current level.Traverse nodes at the next level in a similar manner.Let us understand with examples.For ExampleInput - level=2Output - Count of number of ...

Read More

Count numbers in a range having GCD of powers of prime factors equal to 1 in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 198 Views

Given two numbers start and end representing a range of positive integers. The goal is to find the count of all the numbers that lie in range [start, end] and have prime factorization such that all prime factors of that number have powers such that they have GCD as 1.If a number has prime factorization as 2p * 3q * 5r ….. Then powers p, q, r ...should have gcd=1.Let us understand with examples.For ExampleInput - start = 1, end = 10 Output - Count of numbers in a range having GCD of powers of prime factors equal to 1 are: 6Explanation ...

Read More

Count of strings that become equal to one of the two strings after one removal in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 564 Views

We are given with two different strings let's say s1 and s2 and the task is to form the string let's say S by combining the unique letters of s1 and s2 and now check whether after removing one character from the string S it is forming a string which will be equal to string s1 OR s2.For ExampleInput - string S1 = "utter", string S2 = "butter"; Output - Count of strings that become equal to one of the two strings after one removal are: 1Explanation -  we are given with string s1 and s2 and we will from string S ...

Read More

Count of Numbers in Range where the number does not contain more than K non zero digits in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 413 Views

We are given an integer range starting from the variable let's say start till the variable end and a variable k and the task is to calculate the count of numbers in the range such that the numbers don't have more than 'k' non-zero digits.For ExampleInput - int start = 50, end = 100 and K = 2;Output - Count of Numbers in Range where the number does not contain more than K non zero digits are: 50Explanation - The range is starting from 50 to 100 and we are given k as 2. As we can see, all the ...

Read More
Showing 401–410 of 5,962 articles
« Prev 1 39 40 41 42 43 597 Next »
Advertisements