Arnab Chakraborty has Published 4452 Articles

C++ code to process query operation on binary array

Arnab Chakraborty

Arnab Chakraborty

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

220 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

99 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

145 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

122 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

60 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

211 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

C++ code to find maximum score we can assign to first student

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 06:52:42

432 Views

Suppose we have an array A with n elements and a number m. There are n students giving an exam. The highest possible score is m. A[i] is the score of ith student. We can manipulate each students score, but the conditions must be satisfied. The score will not exceed ... Read More

C++ code to find minimum arithmetic mean deviation

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 06:50:12

166 Views

Suppose we have an array A with 3 elements. A[1] is arithmetic mean of two elements A[0] and A[3] if A[0] + A[2] = 2 * A[1]. Arithmetic mean deviation of three numbers d(A[0], A[1], A[2]) is |A[0] + A[2] - 2*A[1]|. We can perform following operations any number of ... Read More

C++ code to find the number of dial rotations to print a string

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 06:40:32

115 Views

Suppose, we are given a rotary dial that contains all lowercase English alphabets. There is a printer attached to the dial and whichever character resides in the pointer of the rotary dial for 3 seconds, gets printed. The rotary dial initially stays at the letter 'a' and it does not ... Read More

C++ code to find the lamps needed to light up a floor

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 06:38:37

270 Views

Suppose, there is a floor divided into a grid that has n rows and m columns. Now the floor has to be lit using lamps. A lamp, if placed at the border of two cells can light up two cells. If the lamp is placed in the vertical border, it ... Read More

Advertisements