Arnab Chakraborty has Published 4452 Articles

C++ program to count number of minutes needed to increase stick length to form a triangle

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 11:07:55

215 Views

Suppose we have three numbers a, b and c. There are three sticks whose lengths are a, b and c. In one minute, we can pick one arbitrary stick and increase its length by 1 cm, but we cannot break sticks. We have to count the minimum number of minutes ... Read More

C++ program to check we can make two strings equal by swapping from third string

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 11:03:25

217 Views

Suppose we have three strings S, T and U of same length n. For every index i in range 0 to n-1, we must swap U[i] with either S[i] or T[i]. So in total we have performed n swapping operations. We have to check whether after such n operations we ... Read More

C++ program to find maximum possible median of elements whose sum is s

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 11:00:07

244 Views

Suppose we have two numbers n and s. We have to find the maximum possible median of an array of n non-negative elements, such that the sum of elements is same as s.So, if the input is like n = 3; s = 5, then the output will be 2, ... Read More

C++ program to find permutation with n peaks

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 10:56:54

201 Views

Suppose we have two numbers n and k. We have to construct a permutation A using the numbers from 1 to n which has exactly k peaks. An index i is said to be peak of an array A, if A[i] > A[i-1] and A[i] > A[i+1]. If this is ... Read More

C++ program to check three items circularly likes next item or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 10:51:51

53 Views

Suppose we have an array A with n elements. There are n planes on Earth and they are numbered from 1 to n. The plane with number i likes plane A[i]. A[i] != i. We have to check whether there are three planes p, q, and r where p likes ... Read More

C++ program to find perfect array of size n whose subarray is a good array

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 10:48:51

144 Views

Suppose we have a number n. An array B is good if the sum of its elements is divisible by the length of this array. We can say an array A with n elements is perfect, if non-empty subarray of this array A is good and elements in A is ... Read More

C++ program to count number of problems can be solved from left or right end of list

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 10:43:31

209 Views

Suppose we have an array A with n elements and another number k is there. Consider there are n problems on a contest. Amal's problem solving skill is k. Amal always solves problem from any of the ends of a list. And He cannot solve problem whose difficulty is greater ... Read More

C++ program to find minimum how many coins needed to buy binary string

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 10:39:43

120 Views

Suppose we have three numbers c0, c1 and h, and a binary string S. We can flip any bit in S. We should pay h coins for each change. After some changes (possibly zero) we want to buy the string. To buy the string we should buy all its characters. ... Read More

C++ program to count how many ways two players win or make draw in dice throwing game

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 10:34:33

166 Views

Suppose we have two numbers a and b. Amal and Bimal are playing a game. First each of them writes an integer from 1 to 6, then a dice is thrown. The player whose written number got closer to the number written on the paper, he wins that round, if ... Read More

C++ program to count minimum number of binary digit numbers needed to represent n

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 10:30:18

238 Views

Suppose we have a number n. A number is a binary decimal if it's a positive integer and all digits in its decimal notation are either 0 or 1. For example, 1001 (one thousand and one) is a binary decimal, while 1021 are not. From the number n, we have ... Read More

Advertisements