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).
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
1 <= i <= size[a]
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.
Problem 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. For […]
Problem The king has many words. For each given word, he needs to find out the number of palindrome anagrams of the string. As the number of anagrams can be large, the king needs the number of anagrams % (109+ 7). Hackerrank Problem Link Input A single line which contains the […]
In mathematics, particularly in the area of arithmetic, a modular multiplicative inverse of an integer a is an integer x such that the product ax is congruent to 1 with respect to the modulus m. Written as: which is the shorthand way of writing the statement that the remainder after dividing ax by […]
ProblemOn the day of the party, the Chef was over-seeing all the food arrangements as well, ensuring that every item was in its designated position. The host was satisfied with everything except the cupcakes. He noticed they were arranged neatly in the shape of a rectangle. He asks the Chef to […]