Arnab Chakraborty has Published 4452 Articles

C++ code to find who cannot give sufficient candies

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:17:25

96 Views

Suppose we have two numbers a and b. There are a and b number of candies in Amal's and Bimal's hand. Amal offered 1 candy to Bimal and Bimal gave two candies to Amal, in the next turn Amal gave 3 candies and Bimal gave 4 and so on. This ... Read More

C++ code to find minimum number starting from n in a game

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:12:58

147 Views

Suppose we have a number n. In a game initially the value of n is v and the player is able to do the following operation zero or more times: Select a positive integer x that x < n and x is not a divisor of n, then subtract x ... Read More

C++ code to find money after buying and selling shares

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:11:01

246 Views

Suppose we have two arrays A of size n, and B of size m, and another number r. There are n opportunities to buy shares. The i-th of them allows to buy as many shares as we want, ith share price is A[i]. And also there are m opportunities to ... Read More

C++ code to find array from given array with conditions

Arnab Chakraborty

Arnab Chakraborty

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

72 Views

Suppose we have an array A with n elements. There is another hidden array B of size n. The elements can be negative or positive. For each index i in range 1 to n, following operations will be performed −Set A[i] as 0 initiallyThen add B[i] to A[i], subtract B[i+1], ... Read More

C++ code to find minimum stones after all operations

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 09:13:25

176 Views

Suppose we have a string S with n characters. The characters will be either '+' or '-'. There is a pile of stones, n times we either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one ... Read More

C++ code to check grasshopper can reach target or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 09:10:54

234 Views

Suppose we have a string S of size n and another number k. The string contains four types of characters. Consider there are few cells, a grasshopper wants to jump to reach the target. Character '.' means that the corresponding cell is empty, character '#' means that the corresponding cell ... Read More

C++ code to count colors to paint elements in valid way

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 09:08:13

182 Views

Suppose we have an array A with n elements. We need to paint elements in colors such that −If we consider any color, all elements of this color must be divisible by the minimal element of the same color.The number of used colors should be minimized.We have to find the ... Read More

C++ code to get minimum sum of cards after discarding

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 09:00:03

103 Views

Suppose we have five numbers in an array T. There are five cards and each card has a number written on them. The ith card has T[i] written on it. We can discard some cards and our goal is to minimize the sum of numbers written on remaining numbers. He ... Read More

C++ code to find a point that satisfies the constraints

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 08:54:56

278 Views

Suppose, we are given two points a = (x1, y1) and b = (x2, y2). The Manhattan distance between two points is dist(a, b) = |x1 - x2| + |y1 - y2|. If the point a's coordinate is (0, 0) and the point b's coordinate is (x, y), we have ... Read More

C++ code for calculation of a physics experiment

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 08:53:03

571 Views

Suppose, we are performing a physics experiment. We are given n pairs of values and a threshold value k. Each the first value of the pair is added to a total value and the second value of the pair is also added to another total value. Now, we check if ... Read More

Advertisements