Sunidhi Bansal

Sunidhi Bansal

809 Articles Published

Articles by Sunidhi Bansal

Page 2 of 81

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

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 337 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 253 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 189 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 552 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 402 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

Count of Numbers in a Range divisible by m and having digit d in even positions in C++

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

We are given with an integer range, a variable m which is used as divisor and a variable d which is used to check whether the digit 'd' is at even position or not and the task is to calculate the count of those numbers in a range which are divisible by the variable m and have digit d in even positions.For ExampleInput - int start = 20, end = 50, d = 8 and m = 4Output - Count of Numbers in a Range divisible by m and having digit d in even positions are: 2Explanation - The range ...

Read More

Count of cyclic permutations having XOR with other binary string as 0 in C++

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

We are given with two binary strings let's say str_1 and str_2 containing the combination of 1's and 0's and the task is to firstly form the set let's say “SET” of different permutations possible from the string str_1 and then we will perform XOR operations of the elements in set with the binary string str_2 and then check whether the XOR is returning 0 or not. If yes, then consider the case else ignore it.Let us understand with examples.For ExampleInput -  string str_1 = "1111", string str_2 = "1111"Output - Count of cyclic permutations having XOR with other binary string ...

Read More

Count of divisors having more set bits than quotient on dividing N in C++

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

We are given with an integer number let's say, N which is considered as a divisor and it will be divided with the numbers starting from the 1 - N and the task is to calculate the count of those divisors which have more number of set bits than the quotient when divided with the given number N.For ExampleInput - int N = 6Output - Count of divisors having more set bits than quotient on dividing N are: 5Explanation - Firstly, we will divide the number N with the numbers starting from 1 - N and calculate the set bits of ...

Read More

Count of arrays having consecutive element with different values in C++

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

Given three variables size, max_val, last_element as input. The goal is to find the count of different arrays that can be formed in a manner such that they have size elements, have elements between 1 and max_val and the first element is always 1 and the last element is always max_val. Also make sure that no two consecutive elements are the same.Let us understand with examples.For ExampleInput - size = 5, max_val = 3, last_element = 3Output - Count of arrays having consecutive element with different values are: 5Explanation - The arrays will be:-[ 1, 2, 3, 1, 3 ], ...

Read More
Showing 11–20 of 809 articles
« Prev 1 2 3 4 5 81 Next »
Advertisements