Given an integer, write a function that returns true if the given number is palindrome, else false. For example, 12321 is palindrome, but 1451 is not palindrome.
Given a number n, write an efficient function to print all prime factors of n. For example, if the input number is 12,
There are two vessels of capacities ‘a’ and ‘b’ respectively. We have infinite water supply. Give an efficient algorithm to make exactly 1 litre of water in one of the vessels.
The value of Exponential Function e^x can be expressed using following Taylor Series. e^x = 1 + x/1! + x^2/2! + x^3/3! + ……
Write code to convert a given number into words. For example, if “1234” is given as input, output should be “one thousand two hundred thirty four”.
There are some glasses with equal capacity as 1 litre. The glasses are kept as follows:
An array of size n is given. The array contains digits from 0 to 9. Generate the largest number using the digits in the array such that the number is divisible by 2, 3 and 5.
Given a stream of numbers, generate a random number from the stream. You are allowed to use only O(1) space and the input is in the form of stream, so can’t store the previously seen numbers.
Pascal’s triangle is a triangular array of the binomial coefficients. Write a function that takes an integer value n as input and prints first n lines of the Pascal’s triangle. Following are the first 6 rows of Pascal’s Triangle.
We know the Pascal’s Identity very well, i.e. ncr = n-1cr + n-1cr-1
Reservoir sampling is a family of randomized algorithms for randomly choosing k samples from a list of n items,