Given a function foo(), that returns an integer between 1 and 5 with equal probability. Write a function using foo() that returns an integer between 1 and 7.
Reservoir sampling is a category of randomised algorithms for choosing a simple random sample, without replacement, of k items
Consider the 2D grid formed by integer points on the XY Plane. The position of the Sniper and the Target are lattice points in this grid. The bullet shot by the Sniper will follow a straight line trajectory from (x1, y1) to (x2, y2). The bullet goes no further than (x2, y2).
The number of possible Binary Search Trees with n keys is Catalan Number (Cn). You could learn about Catalan Number & Binomial Coefficient.
Catalan numbers (Cn) are a sequence of natural numbers. Nth Catalan number has applications in many counting problems.
The recomputations in calculating binomial coefficient (nCr) can be avoided by exploiting optimal substructure and overlapping subproblems
Given an integer range, for all M in that inclusive range, determine the minimum – abs(arr[i]-M) for all i
Jim is doing his discrete maths homework which requires him to repeatedly calculate nCr(n choose r) for different values of n
Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.
A simple recursive method to generate a numeric palindrome from any number is to reverse its digits and add it to the original. If the sum is not a palindrome (which means, it is not the same number from left to right and right to left), repeat this procedure.