Given an integer L, the task is to find the maximum of all the integers present at the given level in Pascal’s triangle.
A Pascal triangle with 6 levels is shown below:
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
Input: L = 3
0th level -> 1
1st level -> 1 1
2nd level -> 1 2 1
3rd level -> 1 3 3 1
Input: L = 5
Approach: It is known that each row in a Pascal Triangle is Binomial Coefficients and the kth coefficient in a binomial expansion for the level n is nCk. Also, the middle element of any level is always the greatest that is k = floor(n / 2).
Hence the maximum of all the integers present at the given level in Pascal’s triangle is binomialCoeff(n, n / 2).
Below is the implementation of the above approach:
- Multiply two integers without using multiplication, division and bitwise operators, and no loops
- Median in a stream of integers (running integers)
- Check whether a given point lies inside a triangle or not
- Significance of Pascal’s Identity
- Pascal's Triangle
- Find the maximum distance covered using n bikes
- Maximum profit by buying and selling a share at most twice
- Find a pair with maximum product in array of Integers
- Count Integral points inside a Triangle
- Count 'd' digit positive integers with 0 as a digit
- Count positive integers with 0 as a digit and maximum 'd' digits
- Querying maximum number of divisors that a number in a given range has
- Maximum profit by buying and selling a share at most k times
- How to sum two integers without using arithmetic operators in C/C++?
- Count maximum points on same line
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.