Sunidhi Bansal has Published 1085 Articles

Count ways to express a number as sum of consecutive numbers in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:15:04

874 Views

Given an integer n as input. The goal is to find the number of ways in which we can represent ‘num’ as the sum of two or more consecutive natural numbers. For example, if n is 3 it can be represented as sum ( 1+2 ) so total 1 way.For ... Read More

Count ways to express ‘n’ as sum of odd integers in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:12:56

340 Views

Given an integer n as input. The goal is to find the number of ways in which we can represent ‘n’ as the sum of odd integers. For example, if n is 3 it can be represented as sum ( 1+1+1 ) and (3) so total 2 ways.For ExampleInputn=6OutputCount of ... Read More

Count ways to divide circle using N non-intersecting chords in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:11:06

435 Views

Given an integer N as input for a number of chords in a circle with 2*N end points. The goal is to count the ways in which we can divide that circle using such chords so that no chord intersects with each other.For N=3, points will be 6, 1 way ... Read More

Count trailing zeros in factorial of a number in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:09:15

2K+ Views

Given an integer number as input. The goal is to find the number of trailing zeroes in the factorial calculated for that number. A factorial of a number N is a product of all numbers in the range [1, N].We know that we get a trailing zero only if the ... Read More

Count Unary Numbers in a Range in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 06:07:22

231 Views

Given two numbers start and end representing a range. The goal is to find the count of Unary numbers existing between [ start, end ].We can check if the number is Unary by following steps: If we take a number 13 then 12 + 32 = 10, then 12 + ... Read More

Count unique numbers that can be generated from N by adding one and removing trailing zeros in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 05:12:50

196 Views

We are given a number N as input. Perform two operations on N and identify the count of unique numbers generated in the process. Steps will −Add 1 to numberRemove trailing zeros from the generated number, if anyIf N is 8 then numbers generated will beApplying step 1− 8 → ... Read More

Count triplets in a sorted doubly linked list whose sum is equal to a given value x in C++

Sunidhi Bansal

Sunidhi Bansal

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

261 Views

Given a sorted doubly linked list containing integer values. The goal is to find triplets whose product is equal to the given value x. If input linked list is 3−4−1−2 and x is 6 then count will be 1 (triplet (3, 1, 2) )For ExampleInputlinked list: [ 3−4−13−5−10−10−0 ] x=20OutputCount ... Read More

Count triplets in a sorted doubly linked list whose product is equal to a given value x in C++

Sunidhi Bansal

Sunidhi Bansal

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

215 Views

Given a sorted doubly linked list containing integer values. The goal is to find triplets whose product is equal to the given value x. If input linked list is 3−4−1−2 and x is 6 then count will be 1 (triplet (3, 1, 2))For ExampleInputlinked list: [ 200−4−16−5−10−10−2 ] x=200OutputCount of ... Read More

Count occurrences of the average of array elements with a given number in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 05:00:41

162 Views

Given an array arr[] containing integer elements and an integer num. The goal is to find the average of each element arr[i] and num and print the count of the number of times that average appeared in the original array.If array arr[] is [ 5, 2, 3 ] and num ... Read More

Count occurrences of a character in a repeated string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 04:56:55

6K+ Views

Given a string str, a character and a positive integer N. The string str is repeated indefinitely. The goal is to find the count of occurrences of character in str in first N characters of repetitions.If str is “abac”, character is ch=‘b’ and N is 10.In first 10 characters of ... Read More

Advertisements