Arnab Chakraborty has Published 4293 Articles

C++ code to count ways to form reconnaissance units

Arnab Chakraborty

Arnab Chakraborty

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

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

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

Arnab Chakraborty

Arnab Chakraborty

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

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

C++ code to count volume of given text

Arnab Chakraborty

Arnab Chakraborty

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

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

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, ... 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

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

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

C++ code to find screen size with n pixels

Arnab Chakraborty

Arnab Chakraborty

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

549 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

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

C++ code to count number of times stones can be given

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:35:34

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

C++ code to find how long person will alive between presses

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:33:35

109 Views

Suppose we have four numbers d, L, v1 and v2. Two presses are initially at location 0 and L, they are moving towards each other with speed v1 and v2 each. The width of a person is d, he dies if the gap between two presses is less than d. ... Read More

Advertisements