Found 7346 Articles for C++

C++ Program to find winner and final price in a second price auction event

Arnab Chakraborty
Updated on 07-Apr-2022 11:14:09

227 Views

Suppose we have an array A with n elements. There is a special type of an auction, which is called the second-price auction. In a regular auction, n bidders place a bid which is price a bidder ready to pay. The auction ends, when each bidder secretly informs the organizer of the auction price he is willing to pay. After that, the auction winner is the participant who offered the highest price. But here, he pay not the price he offers, but the highest price among the offers of other participants (the second-price auction). A[i] is the price offered by ... Read More

C++ Program to find array of candy distribution to m friends

Arnab Chakraborty
Updated on 07-Apr-2022 11:11:37

220 Views

Suppose we have two numbers n and m. Amal has n candies and m friends. He wants to make a present with candies to each friend. Amal is planning to present all candies and he wants to do this in the most equal manner. He wants to choose such A[i], where A[i] is the number of candies in the i-th friend's present, the maximum A[i] differs from the least A[i] as little as possible. We have to find the array A.Problem CategoryVarious problems in programming can be solved through different techniques. To solve a problem, we have to devise an ... Read More

C++ program to distribution of apples for two mice

Arnab Chakraborty
Updated on 07-Apr-2022 11:08:41

337 Views

Suppose we have a number n and two arrays A and B of different sizes. There are two mice: m1 and m2. We put n apples in front of them. We know which apples m1 likes. Similarly, we also know which apples m2 likes. We do not want any conflict between the mice (as they may like the same apple), so we decided to distribute the apples between the mice on our own. We are going to give some apples to m1 and some apples to m2. It doesn't matter how many apples each mouse gets but it is important ... Read More

C++ Program to find joining year from the course year lists

Arnab Chakraborty
Updated on 07-Apr-2022 11:04:58

96 Views

Suppose we have an array A with n elements. In a university for each course there is the special group whose name equals the year of university entrance of corresponding course of students at the university. Each of students joins the group of his course and joins all groups for which the year of student's university entrance differs by no more than x years from the year of university entrance of this student. The value of x is not given, but it can be determined from the available data. A is a list of groups which the student Amal joined. ... Read More

C++ Program to find length of country code from phone numbers

Arnab Chakraborty
Updated on 07-Apr-2022 11:01:29

427 Views

Suppose we have a list of strings S with n numeric strings. Amal has n friends in a city. Amal knows phone numbers of all his friends: they are stored in S. All strings in S are of same length. Once Amal needed to figure out the city phone code. He assumed that the phone code of the city is the longest common prefix of all phone numbers of his friends. We have to find the length of the city phone code.Problem CategoryTo solve this problem, we need to manipulate strings. Strings in a programming language are a stream of ... Read More

C++ Program to find cell where next robbery is going to happen

Arnab Chakraborty
Updated on 07-Apr-2022 10:58:18

85 Views

Suppose we have a 2D matrix of characters of size n x m. Where '*' and '.' two types of characters are present. Only three '*'s are there, representing there are 3 robberies, and all other places are marked as '.'. A detective got an information that the fourth robbery will be committed in such cell, that all four robbed cells will form the vertices of some rectangle, parallel to the sides of the map. We have to find the cell.Problem CategoryAn array in the data structure is a finite collection of elements of a specific type. Arrays are used ... Read More

C++ Program to find rounded numbers to save kingdom

Arnab Chakraborty
Updated on 07-Apr-2022 10:52:30

109 Views

Suppose we have a string S where a decimal real number is given. There is a king called Amal, and his son Bimal is in a kingdom. There are other citizens also. They lived happily until great trouble came into the Kingdom. The monsters settled there. Most damage those strange monsters inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who sell, exactly 0.273549107 potion barrels. To deal with the problem somehow, the King Amal issued an order obliging rounding up all numbers to ... Read More

C++ Program to find which episode we have missed to watch

Arnab Chakraborty
Updated on 07-Apr-2022 10:48:05

106 Views

Suppose we have an array A with n elements. There are n episodes of a TV series. They are numbered from 1 to n. We have watched episodes written in array A, but missed one. We have to find which episode we have missed.Problem CategoryVarious problems in programming can be solved through different techniques. To solve a problem, we have to devise an algorithm first and to do that we have to study the particular problem in detail. A recursive approach can be used if there is a recurring appearance of the same problem over and over again; alternatively, we ... Read More

C++ Program to find ways to get a and b numbers of chores by brothers

Arnab Chakraborty
Updated on 07-Apr-2022 10:45:25

145 Views

Suppose we have an array A with n elements and two values a and b. Amal and Bimal are two brothers. Their parents left them home alone and commissioned them to do n chores. Each chore has its complexity. The complexity of the i-th chore equals A[i]. Amal is older, he wants to take the chores with complexity larger than some value x (A[i] > x) to leave to Bimal the chores with complexity less than or equal to x (A[i] ≤ x). Amal will do exactly a number of chores and Bimal will do exactly b number of chores ... Read More

C++ Program to check whether given password is strong or not

Arnab Chakraborty
Updated on 07-Apr-2022 10:41:27

894 Views

Suppose we have a string S. S is a password. If a password is complex, if it meets all of the following conditions −Password length is at least 5 characters;Password contains at least one uppercase letter;Password contains at least one lowercase letter;Password contains at least one digit.We have to check the quality of the password S.Problem CategoryTo solve this problem, we need to manipulate strings. Strings in a programming language are a stream of characters that are stored in a particular array-like data type. Several languages specify strings as a specific data type (eg. Java, C++, Python); and several other ... Read More

Advertisements