Sunidhi Bansal has Published 1100 Articles

Count Pairs of Consecutive Zeros in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:32:40

228 Views

We have a sequence generator that starts with 1. At each step 0 becomes 10 and 1 becomes 01. So following changes will occur at consecutive steps −Step 1 − 01Step 2 − 1001Step 3 − 01101001 ……The goal is to find the number of pairs of consecutive 0’s for ... Read More

Count palindrome words in a sentence in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:30:31

2K+ Views

We are given a string containing an English sentence. The goal is to find the number of words in the string that are palindromes. Palindrome words are those that when read from start or end have the same alphabet sequence. If the sentence is “Madam speaks good Malayalam”, then count ... Read More

Count paths with distance equal to Manhattan distance in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:28:09

356 Views

We are given variables x1, x2, y1, y2 representing two points on a 2D coordinate system as (x1, y1) and (x2, y2). The goal is to find all the paths that will have distance equal to the Manhattan distance between these two points.Manhattan DistanceManhattan Distance between two points (x1, y1) ... Read More

Count passing car pairs in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:26:13

233 Views

We are given an array of length N containing 0’s and 1’s only. The value 1 represents a car going towards west direction and value 0 represents a car going towards east direction.We count passing cars as 1 if a pair of car A and car B is such that 0

Count pairs of natural numbers with GCD equal to given number in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:25:00

899 Views

We gave three input variables as ‘start’, ‘end’ and ‘number’. The goal is to find pairs of numbers between start and end that have GCD value equal to ‘number’. For example GCD(A, B)=number and both A, B are in range [start, end].Let us understand with examples.Input − start=5 end=20 number=8Output ... Read More

Count pairs with average present in the same array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:20:18

189 Views

We are given an array of integers such that each element of the array is in the range [- 1000, 1000]. The goal is to find pairs of elements of the array such that their average is also present in that array. If array is arr[]= [1, 2, 3, 4]. ... Read More

Count pairs of numbers from 1 to N with Product divisible by their Sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:18:23

137 Views

We are given a number N. The goal is to find the pairs of numbers from 1 to N such that the product of pairs is equal to the sum of pairs.Let us understand with examples.Input − N=11Output − Count of pairs of no. from 1 to N with Product ... Read More

Count the number of carry operations required to add two numbers in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:16:24

2K+ Views

We are given two numbers num_1 and num_2. The goal is to count the number of carry operations required if the numbers are added. If numbers are 123 and 157 then carry operations will be 1. (7+3=10, 1+2+5=8, 1+1=2 ).Let us understand with examplesInput − num_1=432 num_2=638Output − Count of ... Read More

Count positive integers with 0 as a digit and maximum ‘d' digits in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 13:06:56

71 Views

We are given a number d which represents the number of digits. The goal is to find the count of positive integers with 0 as a digit and have maximum d digits. Count all 1 digit, 2 digit, 3 digit….d digit positive numbers containing at least one 0.We will first ... Read More

Count the number of rhombi possible inside a rectangle of given size in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 13:04:39

129 Views

We are given a rectangle with dimensions as height X width. The rectangle is represented on a 2D coordinate system with the left-lower corner at point (0, 0). So the goal is to count the number of rhombi possible inside this rectangle such that all these conditions are met −The ... Read More

Advertisements