Arnab Chakraborty has Published 4293 Articles

C++ code to find card spread way to make all sum equal for each player

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 04:51:50

168 Views

Suppose we have an array A with n elements. Here n is even. A[i] is a number written on ith card. There are n/2 people who want to play a game. At the beginning, each player will take two cards. We have to find the way to distribute cards in ... Read More

C++ code to count number of operations to make two arrays same

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 04:46:15

235 Views

Suppose we have two arrays A and B with n number of elements. Consider an operation: Select two indices i and j, then decrease ith element by 1 and increase jth element by 1. Each element of the array must be non-negative after performing an operation. We want to make ... Read More

C++ code to find minimum operations to make numbers c and d

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 07:20:07

342 Views

Suppose we have two numbers c and d. Amal has two numbers a and b initially both are zero. Amal wants to perform some operation on them. Before performing each operation, some positive integer k is picked, which is then used to perform one of the following operations −add number ... Read More

C++ code to check phone number can be formed from numeric string

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 07:17:41

954 Views

Suppose we have a string S with n digits. A number with exactly 11 digits is a telephone number if it starts with '8'. In one operation, we can remove one digit from S. We have to check whether we can make the string a valid phone number or not.So, ... Read More

C++ code to process query operation on binary array

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 07:15:51

347 Views

Suppose we have an array A with n elements and another list of queries Q with q queries. each Query[i] contains a pair (x, k). When we process a query, for x: decrease the value of A[x] by 1. For k, print kth largest element. Initially all elements in A ... Read More

C++ code to check pack size can be determined from given range

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 07:06:35

176 Views

Suppose we have two numbers l and r. There is a shop and we want to sell some food container with 'a' number of foods with a discount, and some customer wants to buy x foods. The customer following a greedy strategy −He buys floor of (x/a) packs with discountThen ... Read More

C++ code to count copy operations without exceeding k

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 07:04:35

178 Views

Suppose we have an array A with n elements and another number k. There are n piles of candies. The ith pile has A[i] number of candies. We can perform the operation on two indices i and j (i != j), then add another A[i] number of candies to A[i] ... Read More

C++ code to check array can be formed from Equal Not-Equal sequence or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 07:02:20

167 Views

Suppose we have a string S of length . Consider there are n numbers and they are arranged in a circle. We do not know the values of these numbers but if S[i] = 'E' it indicates ith and (i+1)th numbers are same, but if that is 'N' then they ... Read More

C++ code to check reengagements can be done so elements sum is at most x

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 06:58:23

111 Views

Suppose we have two arrays A and B of size n, and another number x. We have to check whether we can rearrange the elements in B, so that A[i] + B[1]

C++ code to find composite numbers whose difference is n

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 06:54:57

304 Views

Suppose we have a number n. We have to find two composite integers (non-prime) a and b, such that a - b = n.So, if the input is like n = 512, then the output will be 4608 and 4096StepsTo solve this, we will follow these steps −print 10*n and ... Read More

Advertisements