Sunidhi Bansal has Published 1085 Articles

Count Uppercase, Lowercase, special character and numeric values in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:55:06

8K+ Views

We are given a string containing Uppercase letters, Lowercase letters, specials characters and number values also. The task is to calculate the frequency of all types of characters, special characters and numeric values in the string.Uppercase Letters − A - Z having ASCII values from 65 - 90 where, 65 ... Read More

Count words in a given string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:50:51

4K+ Views

We are given with a sentence or string containing words that can contain spaces, new line characters and tab characters in between. The task is to calculate the total number of words in a string and print the result.Input − string str = “welcome to tutorials point\t”Output − Count of ... Read More

Counting frequencies of array elements in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:48:21

16K+ Views

We are given an array of integer elements which contains duplicate values and the task is to calculate the frequencies of the distinct elements present in an array and print the result.Input − int arr[] = {1, 1, 2, 3, 4, 1, 2, 3}Output −frequency of 1 is: 3 frequency ... Read More

Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:43:35

316 Views

We are given two numbers L and R that define a range [L, R]. The goal is to find all numbers between L and R that are even, and sum of whose digits is divisible by 3.We will do this by calculating the sum of digits of all even numbers ... Read More

Count number of substrings with numeric value greater than X in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:40:51

272 Views

We are given a string of numbers 0 to 9. The string represents a decimal number. The goal is to find all substrings that represent a decimal number which is greater than number X. Condition is that substring should not start with 0. I.e in “2021”, “02”, “021”. “0” will ... Read More

Counting even decimal value substrings in a binary string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:37:31

229 Views

We are given with a string of 0’s and 1’s only. The string represents a binary number read from left to right. i.e. 001 is 4 and not 1. The goal is to find all substrings that represent an even decimal number.We will do this by checking the first value ... Read More

Count of quadruplets with given Sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:35:16

234 Views

We are given with four arrays. Goal is to find quadruplets of elements from the four arrays that have sum equal to a given Sum value. The elements selected should be such that all 4 elements belong to different arrays.We will do this by traversing all arrays using for loop ... Read More

Maximize number of nodes which are not part of any edge in a Graph in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:31:49

119 Views

We are given a graph containing nodes and edges. The goal is to find the maximum number of possible nodes that are connected to any edge of the graph. We know that no. of nodes will always be less than or equal to the number of edges in a complete ... Read More

Count of elements whose absolute difference with the sum of all the other elements is greater than k in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:29:59

239 Views

We are given an array of integers. The goal is to count numbers such that the absolute difference between the sum of all elements and that element is greater than variable k.We will do this by getting the sum of elements of the array. Now for each element arr[i], check ... Read More

Count of numbers which can be made power of 2 by given operation in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 08:27:46

363 Views

We are given an array of positive integers. The goal is to find the count of numbers that can be made power of two by adding 1 to them utmost once.We will check using log2(i) that number is power of two or can become power of two by adding 1 ... Read More

Advertisements