Arnab Chakraborty has Published 4293 Articles

Find maximum in stack in O(1) without using additional stack in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 11:02:20

609 Views

Suppose we want to make a stack that can store the maximum element in the stack. And we can get it in O(1) time. The constraint is that, it should not use any additional space, so O(1) extra space.We can make one user-defined stack, that will store the max value, ... Read More

Find k’th character of decrypted string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 10:56:25

623 Views

Suppose we have one encoded string, where repetitions of substrings are represented as substring followed by count of substrings. So if the string is like ab2cd2, it indicates ababcdcd, and if k = 4, then it will return kth character, that is b here.To solve this, we initially take empty ... Read More

Find if a molecule can be formed from 3 atoms using their valence numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 10:51:32

102 Views

As we know the valance number is the number that defines how-many bonds the atom must form with other atoms. We have the valance numbers of three atoms. We have to check whether they can make one molecule or not. Atoms can form multiple bonds with each other. So if ... Read More

Find i’th index character in a binary string obtained after n iterations in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 10:46:00

244 Views

Suppose we have a binary string bin. Then apply n iterations on it, and in each iteration 0 becomes 01 and 1 becomes 10, after that ith index character in the string after nth iteration. So if the binary string is 101, and n = 2, and i = 3, ... Read More

Find height of a special binary tree whose leaf nodes are connected in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 10:40:20

240 Views

Suppose we have a special binary tree, whose leaf nodes are connected to form a circular doubly linked list. We have to find its height. So the left pointer of the left most leaf will act as previous pointer of circular doubly linked list, and its right pointer will act ... Read More

Find coordinates of the triangle given midpoint of each side in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 10:19:20

195 Views

Suppose we have three coordinates which are midpoint of sides of the triangle. We have to find the coordinates of the triangle. So if the inputs are like (5, 3), (4, 4), (5, 5), then output will be (4, 2), (4, 6), (6, 4).To solve this, we have to solve ... Read More

Find closest number in array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 10:16:42

3K+ Views

Suppose we have an array A with n elements. And elements are sorted. We have to find the closest value to the given integer. The array may contain duplicate values and negative numbers. So if the array is like [2, 5, 6, 7, 8, 8, 9] and the target number ... Read More

Find the version of the Pandas and its dependencies in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Nov-2019 10:09:29

239 Views

Pandas is the important package for data analysis in Python. There are different versions available for Pandas. Due to some version mismatch, it may create some problems. So we need to find the version numbers of the Pandas. We can see them easily using the following code.We can use the ... Read More

Find the smallest number X such that X! contains at least Y trailing zeros in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Nov-2019 10:06:31

121 Views

We have to take a number Y, we will find smallest number X, such that X! contains at least Y number of training zeros. For example, if Y = 2, then the value of X = 10. As X! = 3228800. It has Y number of zeros.We can solve this ... Read More

Find the smallest and second smallest elements in an array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Nov-2019 10:03:23

2K+ Views

Suppose we have an array of n elements. We have to find the first, second smallest elements in the array. First smallest is the minimum of the array, second smallest is minimum but larger than the first smallest number.Scan through each element, then check the element, and relate the condition ... Read More

Advertisements