Find Maximum Score of Bit Removal Game in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:39:41

181 Views

Suppose we have a binary string S with n bits. Amal and Bimal are playing a game. Amal moves first, then Bimal, and they move alternatively. During their move, the player can select any number (not less than one) of consecutive equal characters in S and remove them. After the characters are removed, the characters to the left side and to the right side of the removed block become adjacent. The game ends when the string becomes empty, and the score of each player will be the number of 1-characters deleted by them. They both wants to maximize their score. ... Read More

Check If String is Strictly Alphabetical in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:33:51

344 Views

Suppose we have a string S with n letters in lowercase. A string is strictly alphabetical string, if it follows the following rule −Write an empty string to TThen perform the next step n times;At the i-th step take i-th lowercase letter of the Latin alphabet and insert it either to the left of the string T or to the right of the string T (c is the i-th letter of the Latin alphabet).We have to check whether S is strictly alphabetical string or not.Problem CategoryTo solve this problem, we need to manipulate strings. Strings in a programming language are ... Read More

Find Matrix with Marked Asterisks Region in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:28:16

196 Views

Suppose we have a n x n grid of characters with dots (.) and asterisks (*). All cells are marked as dot except two cells. We have to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes. If there are multiple solutions available, return any one of them.Problem CategoryAn array in the data structure is a finite collection of elements of a specific type. Arrays are used to store elements of the same type in consecutive memory locations. An array is assigned a particular name and it is referenced ... Read More

Check if String Can be Reduced to 2022 in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:18:57

204 Views

Suppose we have a numeric string S with n digits. We perform the following operation with the string S, no more than once. We select two numbers i and j (1 ≤ i ≤ j ≤ n) and removes characters from S string from positions i to j. We have to check whether the string S can be reduced to 2022 in no more than one operations 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 ... Read More

Check if K Rupees are Enough to Reach Final Cell in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:15:00

158 Views

Suppose we have three numbers n, m and k. There is a n x m grid. we are currently at cell (0, 0) top left corner and we want to reach cell (n - 1, m - 1). We can move to the neighboring cells to the right or down. To reach down, it will take x rupees, and to reach right cell, it will take y rupees. We have to check whether we can reach cell (n - 1, m - 1) spending exactly k rupees or not. (The x and y are the current x and y coordinate ... Read More

Get Largest Sum from Digits of 256 and 32 in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:12:32

140 Views

Suppose we have four numbers a, b, c and d. In a box there are some numeri digits. There are 'a' number of digits 2, 'b' number of digits 3, 'c' number of digits 5 and 'd' number of digits 6. We want to compose numbers 32 and 256 from these digits. We want to make the sum of these integers as large as possible. (Each digit can be used no more than once, and unused digits are not counted in the sum).Problem CategoryThe above-mentioned problem can be solved by applying Greedy problem-solving techniques. The greedy algorithm techniques are types ... Read More

Find Winner of Unique Bidding Game in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:09:40

358 Views

Suppose we have an array A with n elements. There are n participants, the i-th participant chose the number A[i]. The winner of the bidding game is such a participant that the number he chose is unique and is minimal. We have to find the index of the participant who won the game. If not possible, return -1.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 ... Read More

Find Minimum Moves to Get All Books Contiguous in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:05:48

284 Views

Suppose we have an array A with n elements. Consider there is a bookshelf and this =can fit n books. The i-th position of bookshelf is A[i], is 1 if there is a book on this position and 0 otherwise. There will be at least one book in the bookshelf. In one move, we can take some contiguous segment [l to r] and −Shift them to the right by 1. This move can be done only if there are empty slots at the right side of r.Shift them to the left by 1: This move can be done only if ... Read More

Count Operations to Make Filename Valid in C++

Arnab Chakraborty
Updated on 08-Apr-2022 08:02:13

201 Views

Suppose we have a string S with n letters. Amal is trying to send a file in the social network, but there is an unexpected problem. If the name of the file contains three or more "x" consecutively, the system considers that the file content does not correspond to the social network. We have the filename in S. We have to check whether the minimum number of characters to be removed S so that, the name does not contain "xxx" as a substring.Problem CategoryTo solve this problem, we need to manipulate strings. Strings in a programming language are a stream ... Read More

Find Minimum K for Candy Distribution in C++

Arnab Chakraborty
Updated on 08-Apr-2022 07:58:31

369 Views

Suppose we have an array A with n elements. Amal has n friends, the i-th of his friends has A[i] number of candies. Amal's friends do not like when they have different numbers of candies. So Amal performs the following set of actions exactly once −Amal chooses k (0 ≤ k ≤n) arbitrary friendsAmal distributes their A[i1] + A[i2] + ... + A[ik] candies among all n friends. During distribution for each of A[i1] + A[i2] + ... + A[ik] candies he chooses new owner. That can be any of n friends. (Any candy can be given to the person, ... Read More

Advertisements