Sunidhi Bansal has Published 1085 Articles

Count number of sub-sequences with GCD 1 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:56:01

379 Views

We are given an array of integer elements and the task is to find the sub-sequences from the given array which are having GCD as 1. GCD is the greatest common divisor of two or more integers that divides the given numbers entirely and greatest amongst all.Input − int arr[] ... Read More

Count number of occurrences (or frequency) in a sorted array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:51:01

2K+ Views

We are given a sorted array of integer type elements and the number let’s say, num and the task is to calculate the count of the number of times the given element num is appearing in an array.Input − int arr[] = {1, 1, 1, 2, 3, 4}, num = ... Read More

Count rows/columns with sum equals to diagonal sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:43:47

185 Views

We are given a matrix which is a 2-D array having rows and columns and the task is to calculate the count of sum of all the rows and columns such that it is equal to the sum of either principal or secondary matrix.Input −int arr[row][col] = {    { ... Read More

Maximum circular subarray sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:38:09

385 Views

We are given an array and the task is to form the subarrays such that the sum of subarrays in a circular fashion will result in a maximum value.Input − int arr[] = {1, 2, 8, 4, 3, 0, 7}Output − Maximum circular subarray sum is − 22Explanation − we ... Read More

Count smaller values whose XOR with x is greater than x in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:33:41

188 Views

We are given an integer number let’s say, x and the task are to count the smaller numbers less than x whose XOR with x will result in a value greater than the XOR value.The truth table for XOR operation is given belowABA XOR B000101011110Input − int x = 11Output ... Read More

Count smaller numbers whose XOR with n produces greater value in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:30:51

131 Views

We are given an integer number let’s say, num and the task is to count the smaller numbers less than num whose XOR with num will result in a value greater than the XOR value..The truth table for XOR operation is given belowABA XOR B000101011110Input − int num = 11Output ... Read More

Count of alphabets having ASCII value less than and greater than k in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:28:41

324 Views

We are given a string of any length and the task is to calculate the count of alphabets having ASCII values less than or greater than or equals to the given integer value k.ASCII value for character A-Z are given belowABCDEFGHIJKLMNOPQRS65666768697071727374757677787980818283TUVWXYZ84858687888990ASCII value for characters a-z are given belowabcdefghijklmnopqrs979899100101102103104105106107108109110111112113114114tuvwxyz116117118119120121122Input − str ... Read More

Count of pairs from 1 to a and 1 to b whose sum is divisible by N in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:24:22

163 Views

We are given an integer array and the task is to count the total number of pairs (x, y) that can be formed using the given array values such that the integer value of x is less than y.Input − int a = 2, b = 3, n = 2Output ... Read More

Count of pairs (x, y) in an array such that x < y in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:22:15

298 Views

We are given an integer array and the task is to count the total number of pairs (x, y) that can be formed using the given array values such that the integer value of x is less than y.Input − int arr[] = { 2, 4, 3, 1 }Output − ... Read More

Count Odd and Even numbers in a range from L to R in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:19:56

435 Views

We are given a range starting from L to R of integer values and the task is to calculate the count of odd numbers and the even numbers in the range.Input − L = 7, R = 17Output − Count of Even numbers in a range from L to R ... Read More

Advertisements