Arnab Chakraborty has Published 4293 Articles

C++ code to find minimum stones after all operations

Arnab Chakraborty

Arnab Chakraborty

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

283 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

299 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

277 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

168 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

335 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

832 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

C++ code to find out which number can be greater

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 08:50:15

472 Views

Suppose, we are given two k-digit numbers m and n. The digits of the numbers are randomly shuffled and then compared. We have to find out which number has a higher probability to be greater.So, if the input is like n = 231, m = 337, k = 3, then ... Read More

C++ code to find out if a name is male or female

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 08:47:28

982 Views

Suppose, we are given n strings in an array 'input'. The strings are names, we have to find out if they are male or female names. If a name ends with 'a', 'e', 'i', or 'y'; it can be said that it is a female name. we print 'male' or ... Read More

C++ code to find the number of scans needed to find an object

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 08:43:19

195 Views

Suppose, we are given a grid of dimensions m x n. An object is placed at cell (ix, iy) and we have to find the object scanning from a starting position (sx, sy). The scanning algorithm scans the ith row and the j-th column of the grid if it is ... Read More

C++ code to find the number of refill packs to be bought

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 08:41:38

208 Views

Suppose, there are 'a' number of matches and 'b' number of press conferences to be held in a stadium in a particular week. There are two cafeterias, one in the player dressing room and one in the press conference area. There are two soft drink dispensers in the cafeterias and ... Read More

Advertisements