Sunidhi Bansal has Published 1100 Articles

Count Possible Decodings of a given Digit Sequence in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 13:02:52

201 Views

We are given a string representing a digit sequence. Each digit is decoded from 1 to 26 as English Alphabet. 1 is ‘A’, 2 is ‘B’ and so on till 26 as ‘Z’. The goal is to find the count of all possible decodings out of a given digit sequence. ... Read More

Count rotations divisible by 8 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:57:52

153 Views

We are given a large number. The goal is to count the rotations of num that are divisible by 8.As the rotations can not be done again and again. We will use the divisible by 8 property. If the last three digits are divisible by 8then the number is divisible ... Read More

Count rotations divisible by 4 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:55:38

602 Views

We are given a large number. The goal is to count the rotations of num that are divisible by 4.As the rotations can not be done again and again. We will use the divisible by 4 property. If the last two digits are divisible by 4 then the number is ... Read More

Count rotations in sorted and rotated linked list in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:52:56

112 Views

We are given a linked list. The list is sorted first and then rotated by K number of nodes. The goal is to find the value of K. If we are given below linked list as input which is rotated by K number of nodes −Then original must have been ... Read More

Count rotations of N which are Odd and Even in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:50:06

114 Views

We are given a number N. The goal is to count the rotations of N that make an odd number and rotations that make an even number. If the number N is 123 its rotations would be 123, 321, 132. The odd rotations are 123 and 321 ( 2 ) ... Read More

Count rows in a matrix that consist of same element in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:48:41

689 Views

We are given a matrix consisting of integers. The goal is to find the number of rows in the matrix that have all identical elements in it.If there is 5X4 matrix as shown −15131111115323577777The answer would be 2, row 1 (having all 1’s) and row 3 (having all 7’s) contain ... Read More

Count special palindromes in a String in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:43:57

552 Views

We are given a string str. The goal is to count all substrings of str that are special palindromes and have length greater than 1. The special palindromes are strings that have either all the same characters or only the middle character as different. For example if string is “baabaa” ... Read More

Count sub-arrays which have elements less than or equal to X in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:42:14

226 Views

We are given an array arr[] containing integers and a variable X. The goal is to count all subarrays of arr[] such that each subarray contains only elements that are less than or equal to X. For example if array is [1, 2, 3] and X=2 then subarrays will be ... Read More

Count subarrays consisting of only 0’s and only 1’s in a binary array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:39:47

424 Views

We are given an array arr[] containing 0’s and 1’s only. The goal is to count all subarrays of arr[] such that each subarray contains only 0’s or only 1’s not both. If the array is [1, 0, 0] .Subarrays will be for 0’s only [0], [0], [0, 0] and ... Read More

Count subarrays having total distinct elements same as original array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:37:35

175 Views

We are given an array arr[] containing integers. The goal is to count all subarrays of arr[] such that the number of distinct elements in each is the same as the number of distinct elements in the original array. If the original array is [1, 1, 2, 3] then subarrays ... Read More

Advertisements