## Lucy and Flowers | HackerRank Solution [Medium]

The number of possible Binary Search Trees with n keys is Catalan Number (Cn). You could learn about Catalan Number & Binomial Coefficient.

## Program for Nth Catalan Number

Catalan numbers (Cn) are a sequence of natural numbers. Nth Catalan number has applications in many counting problems.

## How to calculate Binomial Coefficient (nCr) in O(r) time complexity

The recomputations in calculating binomial coefficient (nCr) can be avoided by exploiting optimal substructure and overlapping subproblems

## nCr table | HackerRank Solution [Medium]

Jim is doing his discrete maths homework which requires him to repeatedly calculate nCr(n choose r) for different values of n

## Common Child | Algorithms | HackerRank Solution [Medium]

Given two strings p and q of equal length, what’s the longest string that can be constructed such that it is a child of both?

## Substring Diff | HackerRank (Algorithms) | Longest Common Substring

Problem In this problem, we’ll use the term “longest common substring” loosely. It refers to substrings differing at some number or fewer characters when compared index by index. For example, ‘abc’ and ‘adc’ differ in one position, ‘aab’ and ‘aba’ differ in two. Given two strings and an integer , determine the […]

## Fibonacci Numbers Solution (O(1) auxiliary space)

In mathematics, the Fibonacci series (Fn) is a sequence, such that each number in the series is the sum of the two preceding ones, starting from 0 and 1. That is, and for n > 1, Problem Statement Input a number n, print n-th Fibonacci Number.  Examples:  Input : n = […]

## Pascal’s Triangle

In mathematics, Pascal’s triangle is a triangular array of the binomial coefficients. It can also be viewed as: each number in Pascal’s triangle is the sum of the two numbers directly above it as shown: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 […]

## Number of ways to climb a stair having n steps – LeetCode Solution [Easy]

You are climbing a staircase. It has n steps upto the top. Each time you can either climb 1 step or 2 steps. You’ve to find the number of ways to climb the stair. Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step […]

## Subset with a given sum and number of subsets

Problem Statement You are given an array of non-negative integers, you have to find if there’s a subset of this array having sum equal to the given sum. Subset needs not to be contiguous. Example:  Input: arr[] = {3, 34, 4, 12, 5, 2}, sum = 8 Output: True Subset (3, […]