Arnab Chakraborty has Published 4293 Articles

Find the number of integers x in range (1,N) for which x and x+1 have same number of divisors in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 07:35:29

159 Views

Suppose, we have an integer N, we have to find the number of integers 1 < x < N, for which x and x + 1 has same number of positive divisors. So if N = 3, then output will be 1, as divisor of 1 is 1, divisor of ... Read More

Find consecutive 1s of length >= n in binary representation of a number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 07:33:51

249 Views

Suppose, we have two integers x and n, our task is to search for the first consecutive stream of 1s (32-bit binary) which is greater than or equal to the value of n in length and return its position. If no such string exists, then return -1. For example, if ... Read More

Find the number of integers from 1 to n which contains digits 0’s and 1’s only in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 07:32:10

193 Views

Suppose, we have a number n. Our task is to find the number of integers from 1 to n, which contains digits 0s and 1s only. So if n = 15, then output will be. As the numbers are 1, 10, 11To solve this, we will create integers using 0s ... Read More

Find common elements in three sorted arrays in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 07:27:05

715 Views

Suppose we have three arrays with some elements. We have to find all the common elements that are present in these three arrays. Suppose these elements are [10, 12, 15, 20, 25], [10, 12, 13, 15] and [10, 12, 15, 24, 25, 26], then the common elements in these three ... Read More

Find the number of binary strings of length N with at least 3 consecutive 1s in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 07:24:56

377 Views

Suppose, we have an integer N, We have to find the number of all possible distinct binary strings of the length N, which have at least three consecutive 1s. So if n = 4, then the numbers will be 0111, 1110, 1111, so output will be 3.To solve this, we ... Read More

Find common elements in three linked lists in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 07:23:38

228 Views

Suppose we have three linked lists. We have to find all the common elements that are present in these three linked lists. Suppose these lists are [10, 12, 15, 20, 25], [10, 12, 13, 15] and [10, 12, 15, 24, 25, 26], then the common elements in these three lists ... Read More

Find the number closest to n and divisible by m in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 07:21:17

2K+ Views

Suppose we have two integers n and m. We have to find the number closest to n and divide by m. If there are more than one such number, then show the number which has maximum absolute value. If n is completely divisible by m, then return n. So if ... Read More

Find closest smaller value for every element in array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 07:12:12

196 Views

Here we will see how to find the closest value for every element in an array. If an element x has the next element that is larger than it, and also present in the array, then that will be the greater value of that element. If the element is not ... Read More

Find smallest number K such that K % p = 0 and q % K = 0 in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 13:10:47

105 Views

Suppose we have two integers P and Q. We have to find smallest number K, such that K mod P = 0 and Q mod K = 0. Otherwise print -1. So if the P and Q are 2 and 8, then K will be 2. As 2 mod 2 ... Read More

Find Selling Price from given Profit Percentage and Cost in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 13:09:23

275 Views

Consider we have the selling price, and percentage of profit or loss is given. We have to find the cost price of the product. The formula is like below −$$Cost Price=\frac{Sell Price∗100}{100+percentage profit}$$ $$Cost Price=\frac{Sell Price∗100}{100+percentage loss}$$Example Live Demo#include using namespace std; float priceWhenProfit(int sellPrice, int profit) {    return (sellPrice ... Read More

Advertisements