Sunidhi Bansal has Published 1100 Articles

Count number of substrings with numeric value greater than X in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:40:51

222 Views

We are given a string of numbers 0 to 9. The string represents a decimal number. The goal is to find all substrings that represent a decimal number which is greater than number X. Condition is that substring should not start with 0. I.e in “2021”, “02”, “021”. “0” will ... Read More

Counting even decimal value substrings in a binary string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:37:31

149 Views

We are given with a string of 0’s and 1’s only. The string represents a binary number read from left to right. i.e. 001 is 4 and not 1. The goal is to find all substrings that represent an even decimal number.We will do this by checking the first value ... Read More

Count of quadruplets with given Sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:35:16

134 Views

We are given with four arrays. Goal is to find quadruplets of elements from the four arrays that have sum equal to a given Sum value. The elements selected should be such that all 4 elements belong to different arrays.We will do this by traversing all arrays using for loop ... Read More

Maximize number of nodes which are not part of any edge in a Graph in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:31:49

56 Views

We are given a graph containing nodes and edges. The goal is to find the maximum number of possible nodes that are connected to any edge of the graph. We know that no. of nodes will always be less than or equal to the number of edges in a complete ... Read More

Count of elements whose absolute difference with the sum of all the other elements is greater than k in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:29:59

178 Views

We are given an array of integers. The goal is to count numbers such that the absolute difference between the sum of all elements and that element is greater than variable k.We will do this by getting the sum of elements of the array. Now for each element arr[i], check ... Read More

Count of numbers which can be made power of 2 by given operation in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:27:46

228 Views

We are given an array of positive integers. The goal is to find the count of numbers that can be made power of two by adding 1 to them utmost once.We will check using log2(i) that number is power of two or can become power of two by adding 1 ... Read More

Count of only repeated element in a sorted array of consecutive elements in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:21:18

5K+ Views

We are given an array of consecutive numbers of length n. The array has only one number which is repeated more than once. The goal is to get the number of times that element is repeated in the array. Or we can say find the length of a repeated element ... Read More

Count numbers upto N which are both perfect square and perfect cube in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:19:15

4K+ Views

We are given a number N. The goal is to count the numbers upto N that are perfect squares as well as perfect cubes. For example, 1, 64 are both perfect squares and perfect cubes.We will use sqrt() to calculate square root and cbrt() to calculate cube root of a ... Read More

Count numbers with unit digit k in given range in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:16:53

361 Views

We are given an interval [first, last]. The goal is to find the count of numbers that have a unit digit k and lie between range [first, last].We will do this by traversing from i=first to i=last. For each number i compare its unit digit with the k, if they ... Read More

Count of m digit integers that are divisible by an integer n in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 12:05:47

190 Views

We are given two integers m and n. The goal is to count m digit numbers that are divisible by n.If m=1, then numbers are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and n=3 then numbers divisible by 3=0, 3, 6, 9 count=4.Let’s understand with examples.Input − ... Read More

Advertisements