
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 7197 Articles for C++

232 Views
Given a score of runs. The goal is to reach that score in a way that the batsman can take either 1 or 2 runs only in a single ball. The restriction is that no 2 runs can be taken consecutively. For example, to reach the given score 6, one can take runs like: 1+2+1+2 but not 2+2+1+1 or any other way with two consecutive 2’s.For ExampleInputscore=4OutputCount of ways to reach a score using 1 and 2 with no consecutive 2s are: 4ExplanationThe ways in which we can reach the score 4 in following ways: 1+1+1+1, 1+1+2, 1+2+1, 2+1+1Inputscore=5OutputCount of ... Read More

1K+ Views
Given two numbers num and power as input. The goal is to find the ways in which num can be represented as a sum of unique natural numbers raised to the given power. If num is 10 and power is 2 then we can represent 10 as 12+32. So total 1 way.For ExampleInputnum=30OutputCount of ways to express a number as sum of powers are: 2ExplanationThe ways in which we can express 30 as sum of powers: 12 + 22 + 52 and 12 + 22 + 32 + 42Inputnum=35OutputCount of ways to express a number as sum of powers are: ... Read More

878 Views
Given an integer n as input. The goal is to find the number of ways in which we can represent ‘num’ as the sum of two or more consecutive natural numbers. For example, if n is 3 it can be represented as sum ( 1+2 ) so total 1 way.For ExampleInputnum=6OutputCount of ways to express a number as sum of consecutive numbers are: 1ExplanationThe ways in which we can express ‘num’ as sum of consecutive natural numbers: 1+2+3Inputnum=19OutputCount of ways to express a number as sum of consecutive numbers are: 1ExplanationThe ways in which we can express ‘num’ as sum ... Read More

342 Views
Given an integer n as input. The goal is to find the number of ways in which we can represent ‘n’ as the sum of odd integers. For example, if n is 3 it can be represented as sum ( 1+1+1 ) and (3) so total 2 ways.For ExampleInputn=6OutputCount of ways to express ‘n’ as sum of odd integers are: 8ExplanationThe ways in which we can express ‘n’ as sum of odd integers − 1. 1+1+1+1+1+1 2. 3+1+1+1 3. 1+3+1+1 4. 1+1+3+1 5. 1+1+1+3 6. 3+3 7. 1+5 8. 5+1Inputn=9OutputCount of ways to express ‘n’ as sum of odd integers ... Read More

437 Views
Given an integer N as input for a number of chords in a circle with 2*N end points. The goal is to count the ways in which we can divide that circle using such chords so that no chord intersects with each other.For N=3, points will be 6, 1 way of getting 3 chords is between 1−2, 3−4, 5−6Other ways −1−6, 2−5, 3−4 1−2, 3−6, 4−5 1−4, 2−3, 5−6 1−6, 2−3, 4−5Total 5 ways.For ExampleInputN=4OutputCount of ways to divide circle using N non-intersecting chords are: 14ExplanationThere will be a total 8 points between which we can draw chords. After drawing ... Read More

2K+ Views
Given an integer number as input. The goal is to find the number of trailing zeroes in the factorial calculated for that number. A factorial of a number N is a product of all numbers in the range [1, N].We know that we get a trailing zero only if the number is multiple of 10 or has a factor pair (2, 5). In all factorials of any number greater than 5, we have a number of 2s more than 5s in prime factorization of that number. Dividing a number by powers of 5 will give us the count of 5s ... Read More

232 Views
Given two numbers start and end representing a range. The goal is to find the count of Unary numbers existing between [ start, end ].We can check if the number is Unary by following steps: If we take a number 13 then 12 + 32 = 10, then 12 + 02 = 1 So the ultimate sum in this way is 1 so 13 is unary.For ExampleInputstart=1 end=20OutputCount of Unary Numbers in a Range are: 5ExplanationThe numbers are : 1, 7, 10, 12, and 13Inputstart=50 end=100OutputCount of Unary Numbers in a Range are: 7ExplanationThe numbers are − 59, 63, 67, ... Read More

197 Views
We are given a number N as input. Perform two operations on N and identify the count of unique numbers generated in the process. Steps will −Add 1 to numberRemove trailing zeros from the generated number, if anyIf N is 8 then numbers generated will beApplying step 1− 8 → 9 →Applying step 2− 1 → ( removed 0 from 10 )Applying step 1: 2 → 3 → 4 → 5 → 6 → 7 → 8 ( same sequence )Count of unique numbers will be 9.For ExampleInputN=21OutputCount of unique numbers that can be generated from N by adding one ... Read More

263 Views
Given a sorted doubly linked list containing integer values. The goal is to find triplets whose product is equal to the given value x. If input linked list is 3−4−1−2 and x is 6 then count will be 1 (triplet (3, 1, 2) )For ExampleInputlinked list: [ 3−4−13−5−10−10−0 ] x=20OutputCount of triplets in a sorted doubly linked list whose product is equal to a given value x are: 2ExplanationTriplets will be: ( 3, 4, 13 ) and ( 10, 10, 0 )Inputlinked list: [ 4−3−1−5−2−4−2 ] x=8OutputCount of triplets in a sorted doubly linked list whose product is equal to ... Read More

216 Views
Given a sorted doubly linked list containing integer values. The goal is to find triplets whose product is equal to the given value x. If input linked list is 3−4−1−2 and x is 6 then count will be 1 (triplet (3, 1, 2))For ExampleInputlinked list: [ 200−4−16−5−10−10−2 ] x=200OutputCount of triplets in a sorted doubly linked list whose product is equal to a given value x are: 3ExplanationTriplets will be: (4, 5, 10), (4, 5, 10) and (10, 10, 2)Inputlinked list: [ 4−3−1−5−2−4−2] x=12OutputCount of triplets in a sorted doubly linked list whose product is equal to a given value ... Read More