Arnab Chakraborty has Published 4293 Articles

C++ code to count number of lucky numbers with k digits

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:42:47

984 Views

Suppose we have an array A with n elements, and also another number x. We know the lucky numbers are are positive numbers whose decimal representation only contains lucky digits 4 and 7. Form the given n positive integers. We have to count how many of those have not more ... Read More

C++ code to find xth element after removing numbers

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:38:35

180 Views

Suppose we have two numbers n and x. First n natural numbers are written on a blackboard. In ith (i starts from 1) operation, we remove ith number from the blackboard. When there are less than i numbers, we stop removal task. We have to find x-th remaining number after ... Read More

C++ code to find maximum stones we can pick from three heaps

Arnab Chakraborty

Arnab Chakraborty

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

213 Views

Suppose we have three numbers a, b and c. There are three heaps of stones with a, b, and c number of stones respectively. Each time we can do these operations −Take one stone from the first heap and two stones from the second heap (when the heaps have necessary ... Read More

C++ code to find number to disprove given prime hypothesis

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:34:12

177 Views

Suppose we have a number n. Let there is a hypothesis "There exists a positive integer n that for each positive integer m number (n·m + 1) is a prime number". We have to find such m as a counter example to disprove this statement.So, if the input is like ... Read More

C++ code to get two numbers in range x with given rules

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:32:01

252 Views

Suppose we have a number x. We have to find two integers a and b, such that both of them will be in between 1 and x, a is divisible by b, a * b > x but a/b < x. If not possible, return -1. So, if the input ... Read More

C++ code to check review vote status and uncertainty

Arnab Chakraborty

Arnab Chakraborty

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

492 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

228 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

176 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

120 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

266 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

Advertisements