Arnab Chakraborty has Published 4293 Articles

Find the last non repeating character in string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:39:55

234 Views

Suppose we have a string str. We have to find the last non-repeating character in it. So if the input string is like “programming”. So the first non-repeating character is ‘n’. If no such character is present, then return -1.We can solve this by making one frequency array. This will ... Read More

Find minimum x such that (x % k) * (x / k) == n in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:38:56

185 Views

Given two positive integers n and k, and we have to find the positive integer x, such that (x % k)*(x / k) is same as n. So if the n and k are 4 and 6 respectively, then the output will be 10. So (10 % 6) * (10 ... Read More

Find the largest number that can be formed with the given digits in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:37:32

312 Views

Suppose we have an array of digits. We have to find the maximum number that can be obtained using all digits of the array. So if the array is like [3, 3, 9, 6, 2, 5], then maximum number can be 965332.From the problem, we can see that we can ... Read More

Find the largest interval that contains exactly one of the given N integers In C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:35:57

204 Views

Suppose we have an array of N distinct integers. We have to find the max element in an interval [L, R] such that the interval contains exactly one of the given N integers and 1

Find minimum steps required to reach the end of a matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:35:01

405 Views

Suppose we have a 2D matrix with positive integers. We have to find the minimum steps required to move from to the end of the matrix (rightmost bottom cell), If we are at cell (i, j), we can go to the cell (i, j+mat[i, j]) or (i+mat[i, j], j), We ... Read More

Find the kth node in vertical order traversal of a Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:33:45

135 Views

Suppose we have a binary tree and a value K. The task is to print the Kth node in the vertical order traversal. If no such node exists, then return -1. So if the tree is like below −The vertical order traversal is like −4 2 1 5 6 3 ... Read More

Find minimum radius such that atleast k point lie inside the circle in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:27:19

366 Views

Suppose we have some points, and one integer k. We have to find minimum radius of a circle whose center is at (0, 0) to cover k points. So if the points are like (1, 1), (-1, -1), (1, -1), and k = 3, then radius will be 2.Here we ... Read More

Find minimum number to be divided to make a number a perfect square in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:24:24

1K+ Views

Suppose we have a number N. We have to find minimum number that divide N to make it perfect square. So if N = 50, then minimum number is 2, as 50 / 2 = 25, and 25 is a perfect square.A number is perfect square if it has even ... Read More

Find the first, second and third minimum elements in an array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:21:51

251 Views

Suppose we have an array of n elements. We have to find the first, second and the third minimum elements in the array. First minimum is the minimum of the array, second min is minimum but larger than the first one, and similarly the third min is minimum but greater ... Read More

Find minimum number of Log value needed to calculate Log upto N in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 11:19:45

129 Views

As we know that log(x*y) = log(x) + log(y). So we will see what are the minimum number of log values are required to calculate all log values from 1 to N. So if N is 6, then output will be 3, as from log(1) to log(6), there are three ... Read More

Advertisements