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

229 Views
Suppose we have an array A with 4 elements. There are 4 bags of candies, ith bag contains A[i] amount of candies. We want to give each bags to one of our two friends. We have to check whether we can distribute these bags in such a way that each friend receives the same amount of candies in total?So, if the input is like A = [1, 7, 11, 5], then the output will be True, because we can give the first and the third bag to the first friend, and the second and the fourth bag to the second ... Read More

348 Views
Suppose we have three numbers N, M and K. Consider there are N blocks they are arranged in a row. We consider following two ways to paint them. The paints of two blocks different if and only if the blocks are painted in different colors in following two ways −For each block, use one of the M colors to paint it. (it is not mandatory to use all colors)There may be at most K pairs of adjacent blocks that are painted in the same color.If the answer is too large, return result mod 998244353.So, if the input is like N ... Read More

375 Views
Suppose we have two ranges (l1, r1), (l2, r2) represents two lines on x-axis. l1 < r1 and l2 < r2. These segments may intersect, overlap or coincide with each other. We have to find two numbers a and b, such that a is in range (l1, r1) and b is in (l2, r2) and a and b are distinct.So, if the input is like l1 = 2; r1 = 6; l2 = 3; r2 = 4, then the output will be a = 3, b = 4, other answers are also possible.StepsTo solve this, we will follow these steps ... Read More

513 Views
Suppose we have two numbers l and r. We have to find an integer x, which is in between l and r (both inclusive) and all digits in x are distinct.So, if the input is like l = 211; r = 230, then the output will be 213.StepsTo solve this, we will follow these steps −for initialize k := l, when k

575 Views
Suppose we have two numbers N and K. Consider there is an undirected graph with N elements. N vertices satisfies the following conditions −The graph is simple and connectedVertices are numbered from 1 to NLet M be the number of edges in the graph. The edges are numbered from 1 to M. The length of the edge is 1. And Edge i connects vertex U[i] to vertex V[i].There are exactly K pairs of vertices (i, j) where i < j, such that the shortest distance between them is 2.If such graph exists, we have to construct that graph. Otherwise return ... Read More

593 Views
Suppose we have two arrays A and B both are with N elements each. Consider Amal and Bimal are playing a game on a board whose cell numbers are numbered from 1 to N. And N-1 roads. Roads are connecting two cells. So ith road is connecting A[i] to B[i]. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. Initially the cell 1 is marked as black color, and cell N is white. Other cells are not colored. Amal plays first, and they are playing alternatively. Amal selects an uncolored cells that is ... Read More

224 Views
Suppose we have a number N. Consider a function gcdSum(x) of a positive integer x which is the gcd of that integer with its sum of digits. We have to find the smallest integer x >= n, such that gcdSum(x) > 1.So, if the input is like N = 31, then the output will be 33, because gcd of 31 and (3+1) is 1. The gcd of 32 and (3+2) is 1, and gcd of 33 and (3+3) is 3.StepsTo solve this, we will follow these steps −for initialize i := n, when i 0, do: ... Read More

178 Views
Suppose we have a numeric string S, and another number M. Let d be the greatest digit in S. We have to find in many different integers not greater than M can be found by choosing an integer n not less than d+1 and seeing S as a base-n number?So, if the input is like S = "999"; M = 1500, then the output will be 3, because S as base 10 number, we get 999, as base 11 number, we get 1197, as base 12 number, we get 1413. These three values are the only ones that we can ... Read More

259 Views
Suppose we have an array A with N elements. Have another number T. Consider Amal is trying to participate in a programming contest. It lasts for T minutes and present N problems. He has A[i] time to solve ith problem. He will choose zero or more problems to solve from the N problems, so that it takes no longer T minutes in total to solve them. We have to find the longest possible time it will take to solve his choice of problems.So, if the input is like T = 17; A = [2, 3, 5, 7, 11], then the ... Read More

151 Views
Suppose we have an array A with n elements, and another value c is there. There is a crazy word processor present in our system where we can type characters but if we do not type for consecutive c seconds, all of the written letters will be removed. A[i] represents the time when we have typed the ith character. We have to find the final number of characters that will remain on the screen after typing all n characters.So, if the input is like A = [1, 3, 8, 14, 19, 20]; c = 5, then the output will be ... Read More