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

492 Views
Suppose we have three numbers x, y and z. On a review site there were x persons who would upvote, y persons who would downvote, and another group of z persons who would vote, but we do not know whether they would upvote or downvote. Each person can vote at most once. If there are more people upvote than downvote, the result will be "+"; if downvote count is greater, the result will be "-"; otherwise the result will be "0". Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). ... Read More

228 Views
Suppose we have an array D with n-1 elements and two values a and b. In an army, there are n ranks numbered from 1 to n. One needs D[i] years to rise from rank i to rank i+1. Amal has just reached new rank 'a' but he wants to reach rank 'b'. We have to count the number of years he will need to reach his goal.So, if the input is like D = [5, 6]; a = 1; b = 3, then the output will be 11.To solve this, we will follow these steps −n := size of ... Read More

176 Views
Suppose we have an array of pairs P. Where P[i] is in the form (l, r), and have another number k. Consider we are going to read a book with n chapters. so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. We have read some pages and marked the page with number k as the first page which was not read. We have to find the number of chapters we have not completely read yet. P[i] represents the chapter page numbers range.So, if the input is like P = ... Read More

120 Views
Suppose we have a number n. Consider we are going to form an array A with n elements. A is sorted in ascending order and all elements are distinct. For every i from 2 to n (considering array index starts from 1) A[i] is not divisible by A[i-1].So, if the input is like n = 7, then the output will be [2, 3, 4, 5, 6, 7, 8]To solve this, we will follow these steps −for initialize i := 2, when i

266 Views
Suppose we have three numbers a, b and c. A singer has 'a' one-minute songs, 'b' tow-minutes song and 'c' three-minutes song. He wants to distribute all songs into two concerts, such that every song should be included to exactly one concert. He wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert. We have to find the minimal possible difference between the concerts durations.So, if the input is like a = 2; b = 1; c = 3, ... Read More

174 Views
Suppose we have a string S with n digits. A substring of S is said to be even if the number represented by this string is also even. We have to find the number of even substrings of S.So, if the input is like S = "1234", then the output will be 6, because the substrings are 2, 4, 12, 34, 234, 1234.To solve this, we will follow these steps −a := 0 n := size of S for initialize i := 0, when i < n, update (increase i by 1), do: if S[i] mod 2 is same ... Read More

334 Views
Suppose we have an array A with n elements (n is odd). A contains a permutation of first n natural numbers. Let there is a function f(i) this takes single argument i in range 0 to n-2, and does the operation: if A[i] > A[i+1], swap the values of A[i] and A[i+1]. We have to count number of iterations to make array A sorted, for the first time.So, if the input is like A = [4, 5, 7, 1, 3, 2, 6], then the output will be 5, because the array states after each iteration is like: [4, 5, 1, ... Read More

230 Views
Suppose we have two numbers a and b. Amal always sets TV volume to 'b' value. But someday Bimal has changed it to 'a' value. The remote has six buttons (-5, -2, -1, 1, 2, 5) using them we can increase or decrease the volume by 1, 2 or 5. Volume can be very large but not negative. We have to count the number of buttons Amal needs to press at minimum to get the volume same as b.So, if the input is like a = 5; b = 14, then the output will be 3, because press +5 to ... Read More

319 Views
Suppose we have a number n. We have to find an array A of size n. There are n tables and each table has 4 chairs. Chairs are numbered from 1 to 4n. It is known that two kids who sit on chairs with numbers a and b (a != b) will indulge if −gcd(a, b) = 1 or, a divides b or b divides a.We want to seat the kids so there are no 2 of the kid that can indulge. More formally. We have to find the chair association.So, if the input is like n = 4, then ... Read More

333 Views
Suppose we have two coordinates (x1, y1) and (x2, y2). A rabbit is pulling food box. He is attached with a rope with only 1 unit sized rope. Rabbit will pull the box to where it is standing before moving out of the way in the same direction by 1 unit. Rabbit can move 1 unit to the right, left, up, or down without pulling the box. In this case, it is not necessary for it to be in exactly 1 unit away from the box. If he wants to pull the box again, it must go to a point ... Read More