Sunidhi Bansal has Published 1100 Articles

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

153 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

92 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

5K+ 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

Count occurrences of a substring recursively in Java

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 04:54:47

8K+ Views

Given two strings str_1 and str_2. The goal is to count the number of occurrences of substring str2 in string str1 using a recursive process.A recursive function is the one which has its own call inside it’s definition.If str1 is “I know that you know that i know” str2=”know”Count of ... Read More

Count of distinct rectangles inscribed in an equilateral triangle in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:50:15

72 Views

We are an equilateral triangle with side length. The goal is to count the number of distinct rectangles that can be present inside the triangle such that horizontal sides of the rectangle are parallel to the base. Also all end points of the rectangle touch the dots as shown.Let us ... Read More

Count of strings where adjacent characters are of difference one in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:42:00

809 Views

We are given a num number as input. The goal is to count the number of possible strings of length num such that all adjacent characters have difference between ascii values as 1.If num is 2 then strings will be “ab”, “ba”, “bc”, “cb”, ……..”yz”, “zy”.Let us understand with examplesInput ... Read More

Count of pairs of (i, j) such that ((n % i) % j) % n is maximized in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:40:23

80 Views

We are given a number num as input. The goal is to find the number of pairs of form (i, j) such that ((num%i)%j)%num is maximized and i and j both are in range [1, num].Let us understand with examplesInput − num=4Output − Count of pairs of (i, j) such ... Read More

Count of occurrences of a “1(0+)1” pattern in a string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:37:52

115 Views

We are given a string str containing 0s, 1s and other alphabets . It also contains patterns of the form “1(0+)1” where 0+ means any number (>0) of consecutive 0s. The goal is to find such patterns ( “1(0+)1” ) inside string str.Let us understand with examplesInput − str = ... Read More

Count of obtuse angles in a circle with ‘k' equidistant points between 2 given points in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:33:06

93 Views

We are given a circle with K equidistant points on its circumference. Also we are given two points A and B. The goal is to count the number of triangles possible using these points such that they have an obtuse angle ACB( angle greater than 90o) inside them. The points ... Read More

Count of Numbers such that difference between the number and sum of its digits not less than L in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:25:07

60 Views

We are given a number N and another number L. The goal is to find the numbers between 1 and N that have a difference between the number itself and the sum of its digits is not less than L.If N=23, L=10 then the count of such numbers will be ... Read More

Advertisements