Arnab Chakraborty has Published 4293 Articles

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

Arnab Chakraborty

Arnab Chakraborty

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

546 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 the number of dial rotations to print a string

Arnab Chakraborty

Arnab Chakraborty

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

187 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

453 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

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

2K+ 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

799 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

904 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

505 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

210 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

414 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

341 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

Advertisements