Arnab Chakraborty has Published 4452 Articles

C++ code to check string is diverse or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:12:34

229 Views

Suppose we have a string S with n lowercase letters. A string is called diverse if it has consecutive letters of the English alphabet and each letter occurs exactly once. (letters 'a' and 'z' are not adjacent). We have to check whether it is diverse or not.So, if the input ... Read More

C++ code to find max ornaments to make decoration good

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:10:40

132 Views

Suppose we have three numbers y, b and r. There are y yellow ornaments, b blue ornaments and r red ornaments for decoration. A decoration will be beautiful, if the number of blue ornaments used is greater by exactly 1 than the number of yellow ornaments, and the number of ... Read More

C++ code to find maximum fruit count to make compote

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:04:29

445 Views

Suppose we have three numbers a, b and c. There are a lemons, b apples and c pears. To make a compote, the fruit ratio will be 1 : 2 : 4. We cannot cut any fruit into pieces. We have to find the maximum total number of lemons, apples ... Read More

C++ code to find rank of student from score table

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:01:52

732 Views

Suppose we have a 2d array of size n x 4. Consider there are n students and their ids are starting from 0 to n-1. Each of them has four scores on English, Geography, Maths and History. In the table, the students will be sorted by decreasing the sum of ... Read More

C++ code to find minimum moves with weapons to kill enemy

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 04:58:48

435 Views

Suppose we have an array A with n elements, and another number H. H is health of an enemy. We have n weapons and damaging power of ith weapon is A[i]. Different weapons can be used to kill the enemy. We cannot use same weapon twice in a row. We ... Read More

C++ code to get updated string with same 'a' and 'b' count

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 04:55:38

117 Views

Suppose we have as string S with even length n. S contains only two types of characters 'a' and 'b'. We want to modify the string so that every its prefix of its length has an equal amount of letters 'a' and 'b'. To achieve that, we can perform the ... Read More

C++ code to find card spread way to make all sum equal for each player

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 04:51:50

105 Views

Suppose we have an array A with n elements. Here n is even. A[i] is a number written on ith card. There are n/2 people who want to play a game. At the beginning, each player will take two cards. We have to find the way to distribute cards in ... Read More

C++ code to count number of operations to make two arrays same

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 04:46:15

172 Views

Suppose we have two arrays A and B with n number of elements. Consider an operation: Select two indices i and j, then decrease ith element by 1 and increase jth element by 1. Each element of the array must be non-negative after performing an operation. We want to make ... Read More

C++ code to find minimum operations to make numbers c and d

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Mar-2022 07:20:07

224 Views

Suppose we have two numbers c and d. Amal has two numbers a and b initially both are zero. Amal wants to perform some operation on them. Before performing each operation, some positive integer k is picked, which is then used to perform one of the following operations −add number ... Read More

C++ code to check phone number can be formed from numeric string

Arnab Chakraborty

Arnab Chakraborty

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

731 Views

Suppose we have a string S with n digits. A number with exactly 11 digits is a telephone number if it starts with '8'. In one operation, we can remove one digit from S. We have to check whether we can make the string a valid phone number or not.So, ... Read More

Advertisements