Found 33676 Articles for Programming

C++ Program to find array after removal from maximum

Arnab Chakraborty
Updated on 08-Apr-2022 11:01:00

158 Views

Suppose we have an array A with n elements and another value k. We want to perform k following operations. One operation is like −Let d is the maximum value of the arrayFor every index i from 1 to n, replace A[i] with d - A[i]We have to find the final sequence.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 through that name in various programming languages. ... Read More

C++ Program to count number of teams can be formed for coding challenge

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

334 Views

Suppose we have two numbers a and b. In a coding challenge, there are 4 slots for participants in a team. There are a number of programmers and b number of mathematicians. We have to count how many teams can be formed, if: each team must have at lease one programmer and at least one mathematician.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 ... Read More

C++ Program to find length of substring song from main song

Arnab Chakraborty
Updated on 08-Apr-2022 10:54:27

162 Views

Suppose we have a string S with n characters and two values l and r. Amal has written song and shared it to Bimal. The song is a string consisting of lowercase English letters. Bimal made up a question about this song. The question is about a subsegment of the song starting from the index l to r. Bimal considers a substring made up from characters on this segment and repeats each letter in the subsegment k times, where k is the index of the corresponding letter in the alphabet. As an example, if the question is about the substring ... Read More

C++ Program to find how many pawns can reach the first row

Arnab Chakraborty
Updated on 08-Apr-2022 10:51:02

275 Views

Suppose we have two binary strings S and T of size n. Consider there is a chessboard of size n by n.Currently, there are some pawns in the n-th row. There are also enemy pawns in the 1-st row. On one move, we can move one of our pawns. A pawn can move one square up (from (i, j) to (i−1, j)) if there is no pawn in the destination square. And a pawn can move one square diagonally up (from (i, j) to either (i−1, j−1) or (i−1, j+1)) if and only if there is an enemy pawn in ... Read More

C++ Program to find maximal achievable diversity of music notes

Arnab Chakraborty
Updated on 08-Apr-2022 10:46:58

190 Views

Suppose we have a string S with n elements. Amal's song consists of n notes, which we will treat as positive integers. The diversity of a song is the number of different notes it contains. We want to make it more diverse. We cannot arbitrarily change the song. Instead, for each of the n notes in the song, she can either leave it as it is or increase it by 1. Given sequence is a song where integer is describing the notes, we have to find out the maximal, achievable diversity.Problem CategoryThe above-mentioned problem can be solved by applying Greedy ... Read More

C++ Program to count minimum problems to be solved to make teams

Arnab Chakraborty
Updated on 08-Apr-2022 10:44:07

395 Views

Suppose we have an array A with n elements. There are n students in a university, n is even. The i-th student has programming skill equal to A[i]. The team leader wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal. Students can solve problems to increase their skill. If they solve one problem, their skill will be increased by 1. We have to find the minimum total number of problems students should solve to form ... Read More

C++ Program to count square root cube root and both in given range

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

489 Views

Suppose we have a number n. We have to count the number of integers x, in range 1 to n such that, that x is a square of a positive integer number or a cube of a positive integer number (or both a square and a cube simultaneously).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 ... Read More

C++ Program to find maximum score of bit removal game

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

178 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

C++ Program to check string is strictly alphabetical or not

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

342 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

C++ Program to find matrix with marked asterisks region

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

190 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

Advertisements