Arnab Chakraborty has Published 4293 Articles

C++ code to find minimum jump to reach home by frog

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:30:48

413 Views

Suppose we have one binary string S with n bits and another number d. On a number line, a frog wants to reach point n, starting from the point 1. The frog can jump to the right at a distance not more than d. For each point from 1 to ... Read More

C++ code to count maximum groups can be made

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Mar-2022 12:27:18

402 Views

Suppose we have an array A with n elements. There were n groups of students. A group is either one person who can write the code with anyone else, or two people who want to write the code in the same team. But the mentor decided to form teams of ... Read More

C++ code to count days to complete reading book

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 12:18:41

316 Views

Suppose we have an array A with n elements and have another value t. On ith day Amal spends A[i] seconds in work. In the free time he reads a book. The entire book will take t seconds to complete. We have to find how many days he will need ... Read More

C++ code to find palindrome string whose substring is S

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 12:01:05

253 Views

Suppose we have a string S with n letters. We have to find another string T, such that T is palindrome and S is subsequence of T.So, if the input is like S = "ab", then the output will be "aabaa" (other answers are also available)StepsTo solve this, we will ... Read More

C++ code to find reduced direction string of robot movement

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:59:08

272 Views

Suppose we have a string S with n letters. The letters are either 'R' or 'U'. On a 2D plane, a robot can go right or up. When it is 'R' it moves right and when it is 'U' it moves up. However the string is too large, we want ... Read More

C++ code to get shortest distance from circular stations

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:56:52

463 Views

Suppose we have two numbers s and t, and another array D with n elements. The circle line of the Dreamland subway has n different stations. We know the distances between all pairs of neighboring stations: D[i] is the distance between station i and i+1, and D[n-1] is the distance ... Read More

C++ code to check given flag is stripped or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:53:56

291 Views

Suppose we have a matrix of size n x m. Each cell will hold one value from 0 to 9. There is a flag should be striped: each horizontal row of the flag should contain squares of the same color, and the colors of the adjacent horizontal rows should be ... Read More

C++ code to find minimum correct string from given binary string

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:49:30

157 Views

Suppose we have a binary string S with n bits. There are no redundant leading zeroes. We can perform two different operations on S −Swap any pair of adjacent bitsReplace all "11" with "1"Let val(S) is decimal representation of S. We have to find minimum correct string, where correct string ... Read More

C++ code to find center of inner box

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:42:12

396 Views

Suppose we have a matrix of size n x m. Cells are either 'W' as white or 'B' as black. Some square inside the table with odd length was painted black. We have to find the center of this square.So, if the input is likeWWBBBWWWBBBWWWBBBWWWWWWWWWWWWWthen the output will be (3, ... Read More

C++ code to find greater number whose factor is k

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:37:21

192 Views

Suppose we have two numbers n and k. We have to find smallest integer x which is greater than n and divisible by k.So, if the input is like n = 5; k = 3, then the output will be 6.StepsTo solve this, we will follow these steps −return n ... Read More

Advertisements