Found 33676 Articles for Programming

C++ Program to check joke programming code is generating output or not

Arnab Chakraborty
Updated on 08-Apr-2022 11:39:37

218 Views

Suppose we have a string S with n characters. In a joke programming language, there are only 4 instructions."H" to print "Hello World""Q" to print its source code"9" to print "99 bottles of juice""+" to increment the value stored in accumulatorInstructions "H" and "Q" are case-sensitive and they must be in uppercase. The characters except these four are ignored. We have a program written in this language. You have to check whether executing this program will produce any output or not.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 check player position is dangerous or not in football match

Arnab Chakraborty
Updated on 08-Apr-2022 11:36:50

408 Views

Suppose we have a binary string S of size n. Amal loves football very much. One day, he was watching a match, he was writing the players' current positions on a piece of paper. The given string is the written position. A zero corresponds to players of one team; a one corresponds to players of another team. If there are at least 7 players of some team standing one after another, then the situation is marked as "dangerous". We have to check whether it is dangerous or not.Problem CategoryTo solve this problem, we need to manipulate strings. Strings in a ... Read More

C++ Program to check April fool news is fake or real

Arnab Chakraborty
Updated on 08-Apr-2022 11:34:14

239 Views

Suppose we have a string S with n characters. As it's the first of April, Amal is suspecting that the news she reads today are fake, and he does not want to look silly in front of all the contestants. He knows that a news is fake if it contains "fool" as a subsequence. We have to check whether the news is really fake or not.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 ... Read More

C++ Program to get minimum perimeter of rectangle whose area is n

Arnab Chakraborty
Updated on 08-Apr-2022 11:31:27

352 Views

Suppose we have a number n. We are developing a project to build a new data center. The plot of this data center will be a rectangle with an area of exactly n square meters. Each side of the data center must be an integer. We want to minimize the impact of the external environment on the data center. For this reason, we want to minimize the length of the perimeter of the data center (that is, the sum of the lengths of its four sides). We have to find the minimum perimeter of a rectangular data center with an ... Read More

C++ Program to get maximum area of rectangle made from line segments

Arnab Chakraborty
Updated on 08-Apr-2022 11:28:51

359 Views

Suppose we have an array A with four lines. Amal wants to draw four line segments on a sheet of paper. The i-th segment to have its length equal to A[i]. These segments can intersect with each other, and each segment should be either horizontal or vertical. Amal wants to draw the segments in such a way that they enclose a rectangular space, and the area of that rectangular space should be as maximum as possible. We have to find the possible area value.Problem CategoryThe above-mentioned problem can be solved by applying Greedy problem-solving techniques. The greedy algorithm techniques are ... Read More

C++ Program to find number of RBS string we can form bracket sequences

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

358 Views

Suppose we have a string S with brackets. There are two types of brackets '(' ')' and '[', ']'. A string is called a regular bracket sequence (RBS) if it follows following types −empty string;'(' | RBS | ')';'[' | RBS | ']';RBS | RBS.Where '|' is a concatenation of two strings. In one move we can select a non-empty subsequence of the string S (not necessarily consecutive) that is an RBS, then remove it from the string and concatenate the remaining parts without changing the order. We have to find the maximum number of moves we can perform.Problem CategoryThe ... Read More

C++ Program to get string typed in different keyboard layout

Arnab Chakraborty
Updated on 08-Apr-2022 11:20:18

478 Views

Suppose we have two string S and T, and another string R. There are two popular keyboard layouts represented in S and T, they differ only in letters positions. All the other keys are the same. In S and T, all keys of the first and the second layouts in the same order. R may have digits also. It is known that it was typed in the first layout, but the writer intended to type it in the second layout. We have to find the string maintaining the second layout. (Since all keys but letters are the same in both ... Read More

C++ Program to find table plate ordering maintaining given conditions

Arnab Chakraborty
Updated on 08-Apr-2022 11:12:45

213 Views

Suppose we have two numbers h and w. The height and width of a table. The table is divided into h × w cells. Into each cell of the table, we can either put a plate or keep it empty. As each guest has to be seated next to their plate, we can only put plates on the edge of the table — into the first or the last row of the rectangle, or into the first or the last column. To make the guests comfortable, no two plates must be put into cells that have a common side or ... Read More

C++ Program to find minimal sum of all MEX of substrings

Arnab Chakraborty
Updated on 08-Apr-2022 11:08:42

297 Views

Suppose we have a binary string S with n bits. Let an operation MEX of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, MEX(001011) is 2, because 0 and 1 occur in the string at least once, MEX(1111) is 0, because 0 is not present and 0 is minimum. From the given string S. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string. ... Read More

C++ Program to get difference between maximum and minimum water in barrels

Arnab Chakraborty
Updated on 08-Apr-2022 11:04:27

291 Views

Suppose we have an array A with n elements and another value k. We have n barrels lined up in a row, they are numbered from left to right from one. Initially, the i-th barrel contains A[i] liters of water. We can pour water from one barrel to another. In one move, we can take two different barrels x and y (the x-th barrel shouldn't be empty) and pour any possible amount of water from barrel x to barrel y. (assume that barrels have infinite capacity). We have to find the maximum possible difference between the maximum and the minimum ... Read More

Advertisements