Arnab Chakraborty has Published 4293 Articles

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

Arnab Chakraborty

Arnab Chakraborty

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

174 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

182 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

410 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

333 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

230 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

C++ code to kid chair association

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:50:15

319 Views

Suppose we have a number n. We have to find an array A of size n. There are n tables and each table has 4 chairs. Chairs are numbered from 1 to 4n. It is known that two kids who sit on chairs with numbers a and b (a != ... Read More

C++ code to find total time to pull the box by rabbit

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:47:43

333 Views

Suppose we have two coordinates (x1, y1) and (x2, y2). A rabbit is pulling food box. He is attached with a rope with only 1 unit sized rope. Rabbit will pull the box to where it is standing before moving out of the way in the same direction by 1 ... Read More

C++ code to count number of notebooks to make n origamis

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:45:32

212 Views

Suppose we have two numbers n and k. In a party there are n invited friends. Amal wants to make invitations in the form of origami. For each invitation, he needs two red papers, five green papers, and eight blue papers. There are infinite number of notebooks of each color, ... Read More

C++ code to find two substrings with one minimal substring

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:43:29

208 Views

Suppose we have a lowercase string S with n characters. We have to find two non-empty substrings P and Q, such that −Both P and Q are subsequences of SFor each index i, S[i] belong to exactly one of P and Q.P is lexicographically minimum as possible.So, if the input ... Read More

C++ program to find winner of card game

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 05:41:48

688 Views

Suppose we have a number n, two arrays A and B of size k1 and k2 respectively. Amal and Bimal are playing interesting card game. There are n cards, numbered 1 to n. Initially the cards are distributed between them. The game goes as follows: on each turn, each player ... Read More

Advertisements