Given a level N, the task is to find the sum of all the integers present at this given level in an Alternating Pascal’s triangle.
An Modified Pascal triangle with 5 levels is as shown below.
1 -1 1 1 -2 1 -1 3 -3 1 1 -4 6 -4 1
Input: N = 1 Output: 1 Input: N = 2 Output: 0
Approach: As we can observe that for even level sum is 0 and for odd level except for 1 sum is also 0. So There can be at most 2 cases:
- If L = 1, then answer is 1.
- Otherwise the answer will always be 0.
Below is the implementation of the above approach:
Time Complexity: O(1)
- Sum of all the numbers present at given level in Pascal's triangle
- Maximum of all the integers in the given level of Pascal triangle
- Sum of all mersenne numbers present in an array
- Sum of all perfect numbers present in an array
- Sum of all palindrome numbers present in an Array
- Sum of all the numbers in the Nth row of the given triangle
- Triangle of numbers arising from Gilbreath's conjecture
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Difference between High Level and Low level languages
- Sum of upper triangle and lower triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Find the Nth element of the modified Fibonacci series
- Find the maximum possible value of the minimum value of modified array
- Find the modified array after performing k operations of given type
- Sum of nth terms of Modified Fibonacci series made by every pair of two arrays
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.