Arnab Chakraborty has Published 4452 Articles

C++ code to find position of students after coding contest

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:58:57

243 Views

Suppose we have an array A with n elements. In a coding contest, in total n students will participate, and before the start, every one of them has some positive rating (integer). A[i] represents the rating of ith student. After the contest ends, every student will end up with some ... Read More

C++ code to find tree height after n days

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:56:23

155 Views

Suppose we have an array A with n elements. A has elements either 0 or 1. There is a tree. In consecutive n days, if A[i] is 0 it is not watered, if it is 1 then it is watered, the flower grows in the following manner −If the tree ... Read More

C++ code to find minimum different digits to represent n

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:50:03

109 Views

Suppose we have a number n. We want to split it into some non-zero digits whose sum is n. We want to find a solution with minimum possible number of different digits.So, if the input is like n = 13, then the output will be [1, 1, 1, 1, 1, ... Read More

C++ code to check all bulbs can be turned on or not

Arnab Chakraborty

Arnab Chakraborty

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

244 Views

Suppose we have a number m and a nested list A with n sub-lists. Consider there are m bulbs, initially all are turned off. There are n buttons and each of them is connected to some set of bulbs. So A[i] is the set of bulbs that can be turned ... Read More

C++ code to count order collected when client calls

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Mar-2022 06:44:25

226 Views

Suppose we have three numbers n, m and z. An office receives calls in every n minutes, and some deliveries come to office in every m minutes. Office is open for z minutes. We have to count the minimum number of orders are collected so there are no pending orders ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

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

802 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

120 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

101 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

105 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

214 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

Advertisements