When we increment n – 1 elements, the relative difference between the highest number and all other numbers effectively decreases by 1.
Nim’s game is played with a set of heaps, each containing a certain number of objects or stones. Two players take turns removing objects from the heaps
“Order Statistics” is a concept discussed in the book “Introduction to Algorithms”. It pertains to finding the ith order statistics of a set of n elements in linear time. ith order statistics is the ith smallest element in a set of n elements.
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