
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++

234 Views
In this problem, we will find the number of pairs of 3 indices so that any adjacent indices don’t have the same value in the pair. We can get the output by checking each pair of 3 indexes, but it can be more time-consuming. Another approach to solving the problem is to take the current index and also take the index from left and right, which doesn’t contain a similar value to the current index's value. This way, we can count the total number of pairs each index can form and sum them to get the output. Problem statement − ... Read More

164 Views
In this problem, we will find total invalid characters in the given string. If total distinct characters till the particular even index is prime, we can say the character is invalid. We can use the map data structure to count the total number of distinct characters while traversing the string. Also, we can use the string of characters to keep track of the distinct digits. Also, for every character, we can check whether its index is even and whether distinct characters are prime. Problem statement – We have given a string alpha containing the N characters. We need to find ... Read More

151 Views
In this problem, we will check if it is possible to divide the given numeric string into two disjoint subsequences such that sum(sub1) * sum(sub2) becomes odd. We need to divide the string into two subsequences such that the sum of the digits of both becomes odd to get the odd multiplication result. Problem statement − We have given a string num_string containing the numeric characters. We need to check whether we can divide the string into two subsequences such that the multiplication of the sum of both subsequences becomes odd. Also, it is given that every character of the ... Read More

343 Views
The problem statement includes counting the odd numbers in N−th row of Pascal’s triangle. A pascal’s triangle is a triangular array where each row represents the binomial coefficients in the expansion of binomial expression. The Pascal’s triangle is demonstrated as below: 1 1 ... Read More

282 Views
The problem statement includes printing the first N terms of the Moser−de Bruijn Sequence where N will be given in the user input. The Moser−de Bruijn sequence is a sequence consisting of integers which are nothing but the sum of the different powers of 4 i.e. 1, 4, 16, 64 and so on. The first few numbers of the sequence include 0, 1, 4, 5, 16, 17, 20, 21, 64....... The sequence always starts with zero followed by the sum of different powers of 4 such as $\mathrm{4^{0}}$ i.e $\mathrm{4^{1}\:i.e\:4, }$ then sum of $\mathrm{4^{0}\:and\:4^{1}\:i.e\:5}$ and so on. In this ... Read More

161 Views
The problem statement includes using Vantieghems theorem for primality test i.e. we will check for a positive number N which will be user input and print if the number is a prime number or not using the Vantieghems theorem. Vantieghem’s Theorem The Vantieghems theorem for primality states that a positive number, N is a prime number if the product of $\mathrm{2^{i}−1}$ where the value of i ranges from 1 to N−1 is congruent to N modulo $\mathrm{2^{N}−1}$ If both the values are congruent then the number N is a prime number else it is not a prime number. Congruent ... Read More

174 Views
The problem statement includes finding the sum of range in a series of first odd numbers then even natural numbers up to N. The sequence consists of all the odd natural numbers from 1 to N and then all the even natural numbers from 2 to N, including N. The sequence will be of size N. We will be provided with a range in the problem for which we need to find out the sum of the sequence within that range, a and b i.e. [a, b]. Here a and b are included in the range. For example, we are ... Read More

290 Views
The problem statement includes printing the sum of product of consecutive binomial coefficients for any positive number, N which will be the user input. The positive coefficients in the binomial expansion of any term are called binomial coefficients. These binomial coefficients can be found out using Pascal's triangle or a direct formula. The formula to calculate the binomial coefficient: $$\mathrm{^nC_{r}=\frac{n!}{(n-r)!r!}}$$ where, n and r can be any positive numbers and r should never be greater than n. Note : The value of 0! is always equal to 1. In this problem, we will be given a positive number N and ... Read More

163 Views
The problem statement includes printing the sum of digits of N, which will be the user input, when written in different bases from 2 to N−1. In this problem, we will be provided any positive integer N and we need to represent that number in a different base numeral system from 2 to N−1 and find the sum of the digit of each different base numeral system. In the base−n numeral system, every digit of the representation of any number in that numeral system from right represents the number of times power of n from 0 to 31. For example, ... Read More

350 Views
The problem statement includes printing the sum of bitwise OR of all possible subsets of a given set. A set is a collection of data of similar type. A subset of any set is a set containing few elements of the set or all the elements of the given set. The number of subsets of any set is given by $\mathrm{2^{n}−1}$, where n is the number of elements in the given set. For example, a={1, 2, 3, 4, 5} is the given set. {1}. {2, 3}, {1, 2, 3, 4} and so on are called subsets of a, as they ... Read More