Arnab Chakraborty has Published 4452 Articles

C++ code to find out if an image is B/W or color

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 06:34:31

1K+ Views

Suppose, we are given an image that contains n pixels. The pixels can be of the following color −'C' (cyan)'M' (magenta)'Y' (yellow)'W' (white)'G' (grey)'B' (black)The color of the i-th pixel is given in the string 'pixels'. Given the string, we have to find out if the given photograph is colorful ... Read More

C++ code to find out the total amount of sales we made

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 06:29:34

627 Views

Suppose, we are selling 4 items and the price of the i-th item is given in the array 'cost[i]'. Now we sell the items in the order given in the string 'items'. We have to find out the total amount of sales that we have made. The string 'items' contain ... Read More

C++ code to find total number of digits in special numbers

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 05:58:58

699 Views

Suppose, we are given an integer number k. We call a number special number if all the digits in that number are the same. For example, 1, 11, 1111 are special numbers. We count the special numbers in order 1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, ... Read More

C++ code to find out the sum of the special matrix elements

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 05:56:21

365 Views

Suppose, we are given a square matrix of dimensions n * n. The following values of the matrix are called special elements −Values that are in the main diagonal.Values that are in the second diagonal.Values of the row that has exactly (n - 1 / 2) rows above it and ... Read More

C++ code to find the area taken by boxes in a container

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 05:52:30

137 Views

Suppose, we have n pairs of boxes that need to be shipped in a square-shaped container. The width of the pair of the boxes is given as a pair (a, b) and they are given in an array 'dimensions'. If we keep the width of the boxes parallel to each ... Read More

C++ code to find out who won an n-round game

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 05:49:01

322 Views

Suppose, there is a two-player game that has n rounds. The scores of the rounds are given in an array 'scores' where each element is of the format {P1 Score, P2 Score}. The player with the higher score wins a round, and a player wins the game if they have ... Read More

C++ code to find out number of battery combos

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 05:45:04

246 Views

Suppose, we have n batteries that can be used a maximum of 5 times. We have some devices that need three batteries and each usage of the device increases the usage count of the batteries by 1. If we have to use the devices k times, we have to find ... Read More

C++ program to find winner of ball removal game

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Mar-2022 09:54:30

160 Views

Suppose we have four numbers n1, n2, k1 and k2. Consider there are 2 boxes, first one has n1 balls and second one has n2 balls. Amal and Bimal are playing the game. In one move they can take from 1 to k1 balls and throw them out, similarly second ... Read More

C++ program to find minimum how much rupees we have to pay to buy exactly n liters of water

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Mar-2022 07:12:40

132 Views

Suppose we have three numbers n, a and b. We want to buy n liters of water. There are only two types of water bottles nearby, 1-liter bottles and 2-liter bottles. The bottle of the first type a rupees and the bottle of the second type costs b rupees. We ... Read More

C++ Program to find minimum possible ugliness we can achieve of towers

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Mar-2022 07:09:47

126 Views

Suppose we have an array A with n elements. Consider there are n block towers in a row. The ith tower has height A[i]. In a single day, we can perform the operation: Select two indices i and j (i != j) and move back from tower i to j. ... Read More

Advertisements