- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7347 Articles for C++
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
133 Views
Given an integer num as input. The goal is to find the number of trailing zeroes in the product 11 X 22 X 33 X…X numnum.For ExampleInputnum=5OutputCount of number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. are: 5ExplanationThe number of 2s and 5s in the product will be: 11 * 22* 33* 44* 55=11 * 22* 33* (22)4* 55. So total 10 2s and 5 5s, minimum is 5 so trailing zeroes will be 5.Inputnum=10OutputCount of number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. are: 5ExplanationThe number of 2s and 5s in the product will be: 11 *22*33*44*55*66 *77*88*99*1010 = 11 *22*33*44*55*66 *77*88*99*(2*5)10. So ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
977 Views
Given a string str[] containing lowercase alphabets only and an integer value k. The goal is to find the number of possible substrings of str that have exactly k distinct elements.For ExampleInputstr= ”pqr” k=2OutputCount of number of substrings with exactly k distinct characters are: 2ExplanationThe substrings having exactly 2 distinct elements are: “pq”, “qr”.Inputstr= ”stristr” k=4OutputCount of number of substrings with exactly k distinct characters are: 10ExplanationThe substrings having exactly 2 distinct elements are: “stri”, “tris”, “rist”, “istr”, “stris”, “trist”, “ristr”, “strist”, “tristr”, “stristr”.Approach used in the below program is as follows −In this approach we will an array array[26] ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
155 Views
Given an array arr[] containing positive numbers. The goal is to find subsets of elements of arr[] such that the median of values of the subset is also present in that set.For ExampleInputarr[] = { 1, 2, 3 }OutputCount of number of subsets whose median is also present in the same subset are: 4ExplanationThe sets with their medians in that same set are: [ 1 ], median is 1 [ 2 ], median is 2 [ 3 ], median is 3 [ 1, 2, 3 ], median is 2Inputarr[] = { 4, 6, 5 }OutputCount of number of subsets whose ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
202 Views
Given an array ar, containing positive numbers and an array GCD[] containing gcd values.The goal is to find the number of subsets of elements of arr[] that have gcd values as given in GCD[].For ExampleInputarr[] = {10, 5, 6, 3}, GCD[] = {2, 3, 5}OutputCount of number of subsets of a set with GCD equal to a given number are: 1 2 2ExplanationThe subsets with GCD equal to 2 is [ 10, 6 ]. Subsets with GCD equal to 3 is [ 3 ], [ 6, 3 ] Subsets with GCD equal to 5 is [ 5 ], [ 10, ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
153 Views
Given sides of rectangles in and range variables first and last. The goal is to find the count of rectangles that have a ratio of their side’s length/breadth lying in the range [ first, last].For ExampleInputrec[] = { { 200, 210 }, { 100, 50 }, { 300, 190}, {180, 200}, {300, 200}} and first = 1.0, last = 1.6OutputCount of number of rectangles such that ratio of sides lies in the range [a, b] are: 4ExplanationThe sides that have ratio in the range [ 1.0, 1.6 ] are : {200, 210}, {300, 190}, {180, 200}, {300, 200}Inputrec[] = { ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
137 Views
Given an array arr[ ] of positive integers. The goal is to find the count of subarrays of arr[ ] that have an average of its elements greater than the average of the rest of the elements of arr[ ] that are not present in it.For ExampleInputarr[ ] = { 3, 2, 4 }OutputCount of number of sub-arrays such that the average of elements present in the sub−array is greater than that do not present in the sub−array are: 2ExplanationThe subarrays are − [ 3 ], [ 2 ], [ 4 ], [ 3, 2 ], [ 2, 4 ], ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
345 Views
Given a string str containing English alphabets. The goal is to find the number of vowels occurring in all the substrings of str. If string is “abcde” then substrings will be “a”, “b”, “c”, “d”, “e”, “ab”, “bc”, “cd”, “de”, “abc”, “bcd”, “cde”, “abcd”, “bcde”, “abcde”. The count of vowels in these substrings is 10. (a and e)For ExampleInputstr = ”aloe”OutputCount the number of vowels occurring in all the substrings of given string are: 14ExplanationThe substrings are: “a”, “l”, “o”, “e”, “al”, “lo”, “oe”, “alo”, “loe”, “aloe”. Total vowels in these are: 14Inputstr=”http”OutputCount the number of vowels occurring in all ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
924 Views
Given two numbers n and m representing the length and breadth of the floor of a room. The goal is to count the number of ways in which this floor can be tiled using the tiles of size 1Xm.For ExampleInputn=3 m=2OutputCount the number of ways to tile the floor of size n x m using 1 x m size tiles are: 3ExplanationThe ways will be three 1x2 tiles arranged as shown below −Inputn=3 m=3OutputCount the number of ways to tile the floor of size n x m using 1 x m size tiles are: 2ExplanationThe ways will be three 1x3 ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
220 Views
Given a 2D matrix with dimensions row X col. The goal is to count the number of ways one can traverse the matrix from cell 0, 0 to cell row, col using only right and down moves, i.e. first move can be 0, 0 to 0, 1 (down) or 1, 0 (right) and not 1, 1(diagonal).For ExampleInputcol = 2; row = 4OutputCount of number of ways to traverse a Matrix are: 4ExplanationThe ways in which we can reach from cell 0, 0 to 2, 4 is shown −Inputcol = 4; row = 3OutputCount of number of ways to traverse a ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
301 Views
Given an array of positive numbers and two integers A and B. Two players are playing a game in which they will reduce numbers in the array. Player 1 can decrease any element of the array by A and player 2 can increase any element of the array by B. The goal is to find the count of numbers that can be reduced to 0 or less by player 1. The first player makes the first move. The number once reduced to 0 or less can’t be taken into consideration by player 2.For ExampleInputarr[] = { 1, 4, 5, 2 ... Read More