Arnab Chakraborty has Published 4452 Articles

C++ code to check review vote status and uncertainty

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:29:49

404 Views

Suppose we have three numbers x, y and z. On a review site there were x persons who would upvote, y persons who would downvote, and another group of z persons who would vote, but we do not know whether they would upvote or downvote. Each person can vote at ... Read More

C++ code to count years to reach certain rank in an army

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:27:22

144 Views

Suppose we have an array D with n-1 elements and two values a and b. In an army, there are n ranks numbered from 1 to n. One needs D[i] years to rise from rank i to rank i+1. Amal has just reached new rank 'a' but he wants to ... Read More

C++ code to count number of unread chapters

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:24:55

114 Views

Suppose we have an array of pairs P. Where P[i] is in the form (l, r), and have another number k. Consider we are going to read a book with n chapters. so that one page of the book belongs to exactly one chapter and each chapter contains at least ... Read More

C++ code to find sorted array with non-divisibility conditions

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:22:46

75 Views

Suppose we have a number n. Consider we are going to form an array A with n elements. A is sorted in ascending order and all elements are distinct. For every i from 2 to n (considering array index starts from 1) A[i] is not divisible by A[i-1].So, if the ... Read More

C++ code to find minimum difference between concerts durations

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:19:00

151 Views

Suppose we have three numbers a, b and c. A singer has 'a' one-minute songs, 'b' tow-minutes song and 'c' three-minutes song. He wants to distribute all songs into two concerts, such that every song should be included to exactly one concert. He wants to make the absolute difference of ... Read More

C++ code to count number of even substrings of numeric string

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:17:15

130 Views

Suppose we have a string S with n digits. A substring of S is said to be even if the number represented by this string is also even. We have to find the number of even substrings of S.So, if the input is like S = "1234", then the output ... Read More

C++ code to find string where trygub is not a substring

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:08:27

103 Views

Suppose we have a string S with n lowercase English letters. We have to reorder the characters in S, so that "trygub" is not a subsequence of the resulting string.So, if the input is like S = "pintontrygubabc", then the output will be "abbcginnoprttuy".StepsTo solve this, we will follow these ... Read More

C++ code to find three numbers whose sum is n

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:05:59

272 Views

Suppose we have a number n. We are going to find three numbers a, b and c, such that a + b + c = n and none of these three numbers are multiple of 3.So, if the input is like n = 233, then the output will be [77, ... Read More

C++ code to count operations to make array sorted

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:59:01

238 Views

Suppose we have an array A with n elements (n is odd). A contains a permutation of first n natural numbers. Let there is a function f(i) this takes single argument i in range 0 to n-2, and does the operation: if A[i] > A[i+1], swap the values of A[i] ... Read More

C++ code to count minimum button click to set volume as before

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:52:56

190 Views

Suppose we have two numbers a and b. Amal always sets TV volume to 'b' value. But someday Bimal has changed it to 'a' value. The remote has six buttons (-5, -2, -1, 1, 2, 5) using them we can increase or decrease the volume by 1, 2 or 5. ... Read More

Advertisements