Arnab Chakraborty has Published 4293 Articles

Increasing Subsequences in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 13:03:37

238 Views

Suppose we have an integer array, our task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2. So if the array is like [4, 6, 7, 7], then the output will be like − ... Read More

Magical String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 13:00:29

757 Views

Suppose there is a string. That string is called a magical string S, that consists of only '1' and '2' and obeys the following rules −The string S is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the string S itself.The first few components ... Read More

Generate Random Point in a Circle in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:57:12

1K+ Views

Suppose we have the radius and x-y positions of the center of a circle, we have to write a function called randPoint() which generates a uniform random point in the circle. So there will be some important points that we have to keep in mind −Input and output values are ... Read More

Ones and Zeroes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:54:30

502 Views

Suppose we have a dominator of m 0s and n 1s respectively. On the other hand, there is an array with binary strings. Now our task is to find the maximum number of strings that we can generate with given m 0s and n 1s. Each 0 and 1 can ... Read More

Matchsticks to Square in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:51:27

348 Views

Suppose there is a little match girl. And we know exactly what matchsticks the little match girl has, we have to find out a way we can make one square by using up all those matchsticks. We should not break any stick, but we can link them up, and each ... Read More

Implement Rand10() Using Rand7() in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:48:08

421 Views

Suppose we have a function rand7 which generates a uniform random integer in the range 1 to 7, we have to write another function rand10 which generates a uniform random integer in the range 1 to 10. We cannot use some library function to generate random numbers.Suppose we want two ... Read More

Bulb Switcher in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:43:29

1K+ Views

Suppose there are n bulbs that are initially switched off. We first turn on all the bulbs. Then, we turn off every second bulb. On the third round, we toggle every third bulb (turning on if it's off or turning off if it's on). Similarly, for the i-th round, we ... Read More

Sum of Mutated Array Closest to Target in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:39:23

331 Views

Suppose we have an integer array arr and a target value target, we have to find the integer value such that when we change all the integers larger than value in the given array will be equal to value, the sum of the array gets as nearest as possible to ... Read More

Divide Array in Sets of K Consecutive Numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:36:17

286 Views

Suppose we have an array of integers nums and a positive integer k, we have to find whether it's possible to divide this array into sets of k consecutive numbers. So we have to return True if its possible otherwise return False. So if the input is like [1, 2, ... Read More

Sequential Digits in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:32:10

443 Views

Suppose we have an integer, that has sequential digits if and only if each digit in the number is one more than the previous digit. We have to find a sorted list of all the integers in the range [low, high] inclusive that have sequential digits. So if the low ... Read More

Advertisements