Arnab Chakraborty has Published 4452 Articles

C++ code to check water pouring game has all winner or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 13:08:18

179 Views

Suppose we have an array A with n elements and have another number s. There is one empty water mug and n non-empty water mugs on the table. In a game, there are few players. In each move, a player takes a non-empty mug of water and pours all water ... Read More

C++ code to find index where this is a hash collision

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 13:05:42

312 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 ... Read More

C++ code to count ways to form reconnaissance units

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 13:02:19

147 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 ... Read More

C++ code to check pattern is center-symmetrical or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:59:02

273 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 ... Read More

C++ code to count volume of given text

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:55:59

157 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 ... Read More

C++ code to count number of weight splits of a number n

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:51:28

124 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, ... Read More

C++ code to find how long TV are on to watch a match

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:48:26

121 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 ... Read More

C++ code to count number of packs of sheets to be bought

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:45:28

104 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 ... Read More

C++ code to find screen size with n pixels

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:42:37

412 Views

Suppose we have a number n. In a display there will be n pixels. We have to find the size of rectangular display. The rule is like below −The number of rows (a) does not exceed number of columns (b) [a

C++ code to number of standing spectators at time t

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:37:28

131 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) ... Read More

Advertisements