Sunidhi Bansal has Published 1085 Articles

Count occurrences of a substring recursively in Java

Sunidhi Bansal

Sunidhi Bansal

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

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

161 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

962 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

133 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

193 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

171 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

133 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

Count of words that are present in all the given sentences in C++

Sunidhi Bansal

Sunidhi Bansal

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

250 Views

We are given multiple sentences in the form of strings. The goal is to count the number of words that exist in all of the sentences.Note − words containing all lowercase letters will be considered onlyIf sentences are −“ I am learning C language ”“ learning new things is easy ... Read More

Count pairs formed by distinct element sub-arrays in C++

Sunidhi Bansal

Sunidhi Bansal

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

144 Views

We are given an array arr[] containing integer elements. The goal is to find the count of pairs that can be formed by elements of sub-arrays of arr[] such that each subarray has only distinct elements. If the array is [ 1, 2, 2, 3, 3 ] then subarrays with ... Read More

Count of triangles with total n points with m collinear in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Dec-2020 07:17:44

199 Views

We are given two variables n and m representing the number of points on a 2D plane. Out of n points, m points are collinear. The goal is to find the number of triangles that can be formed using these n points.Collinear points − The points that lie on the ... Read More

Advertisements