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

416 Views
Suppose we have a number p and another array X with n elements. There is a hash table with p buckets. The buckets are numbered from 0 to p-1. We want to insert n numbers from X. We are assuming for X[i], its bucket will be selected by the hash function h(X[i]), where h(k) = k mod p. One bucket cannot hold more than one element. If We want to insert an number into a bucket which is already filled, we say a "collision" happens. We have to return the index where collision has happened. If there is no collision, ... Read More

219 Views
Suppose we have an array A with n elements, and another number d. According to the regulations of Dreamland's army, a reconnaissance unit should have exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. There are n soldiers whose heights are stored in the array A. Some soldiers are of the same height. We have to find how many ways exist to form a reconnaissance unit from these n soldiers.So, if the input is like A = [10, 20, 50, 60, 65]; d = 10, then the output will be ... Read More

387 Views
Suppose we have a 3 x 3 matrix with 'X' and '.'. We have to check whether the pattern is centersymmetrical or not. (More on center symmetry − http://en.wikipedia.org/wiki/Central_symmetry)So, if the input is likeXX.....XXthen the output will be True.StepsTo solve this, we will follow these steps −if M[0, 0] is same as M[2, 2] and M[0, 1] is same as M[2, 1] and M[0, 2] is same as M[2, 0] and M[1, 0] is same as M[1, 2], then: return true Otherwise return falseExampleLet us see the following implementation to get better understanding −#include using namespace std; ... Read More

224 Views
Suppose we have a string S with n characters. S is a single-space separated words, consisting of small and capital English letters. Volume of the word is number of capital letters in the given word. And volume of the text is maximum volume of all words in the text. We have to find the volume of the given text.So, if the input is like S = "Paper MILL", then the output will be 4, because volume of first word is 1 and second word is 4, so maximum is 4.StepsTo solve this, we will follow these steps −ans := 0 ... Read More

207 Views
Suppose we have a number n. We can split n as a nonincreasing sequence of positive integers, whose sum is n. The weight of a split is the number of elements in the split that are equal to the first element. So, the weight of the split [1, 1, 1, 1, 1] is 5, the weight of the split [5, 5, 3, 3, 3] is 2 and the weight of the split [9] equals 1. We have to find out the number of different weights of n's splits.So, if the input is like n = 7, then the output will ... Read More

178 Views
Suppose we have an array A with n elements. Amal wants to watch a match of 90 minutes and there is no break. Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Amal immediately turns off the TV. There will be n interesting minutes represented by the array A. We have to calculate for how many minutes Amal will watch the game.So, if the input is like A = [7, 20, 88], then the output will be 35, because after 20, he will still watch the game till 35, then turn off it.StepsTo solve ... Read More

167 Views
Suppose we have four numbers k, n, s and p. To make a paper airplane, Rectangular piece of papers are used. From a sheet of standard size we can make s number of airplanes. A group of k people decided to make n airplanes each. They are going to buy several packs of paper, each of them containing p sheets, and then distribute the sheets between the other people. Each person should have enough sheets to make n different airplanes. We have to count the number of packs should we buy?So, if the input is like k = 5; n ... Read More

177 Views
Suppose we have three numbers n, k and t. Amal is analyzing Mexican waves. There are n spectators numbered from 1 to n. They start from time 0. At time 1, first spectator stands, at time 2, second spectator stands. At time k, kth spectator stands then at time (k+1) the (k+1) th spectator stands and first spectator sits, at (k+2), the (k+2)th spectator stands but 2nd one sits, now at nth time, nth spectator stands and (n-k)th spectator sits. At time (n+1), the (n+1-k)th spectator sits and so on. We have to find the number of spectators stands at ... Read More

212 Views
Suppose we have a number n. Amal gives some stones to Bimal and he gives stones more than once, but in one move if Amal gives k stones, in the next move he cannot give k stones, so given stones in one move must be different than the previous move. We have to count the number of times Amal can give stones to Bimal.So, if the input is like n = 4, then the output will be 3, because 1 stone then 2 stones then again 1 stones.StepsTo solve this, we will follow these steps −return (n * 2 + ... Read More