# Degree of Polynomial solution codechef

## Degree of Polynomial solution codechef

In mathematics, the degree of polynomials in one variable is the highest power of the variable in the algebraic expression with non-zero coefficient.

Chef has a polynomial in one variable xx with NN terms. The polynomial looks like A0x0+A1x1++AN2xN2+AN1xN1A0⋅x0+A1⋅x1+…+AN−2⋅xN−2+AN−1⋅xN−1 where Ai1Ai−1 denotes the coefficient of the ithith term xi1xi−1 for all (1iN)(1≤i≤N).

Find the degree of the polynomial.

Note: It is guaranteed that there exists at least one term with non-zero coefficient.

## Degree of Polynomial solution codechef

### Input Format

• First line will contain TT, number of test cases. Then the test cases follow.
• First line of each test case contains of a single integer NN – the number of terms in the polynomial.
• Second line of each test case contains of NN space-separated integers – the ithith integer Ai1Ai−1 corresponds to the coefficient of xi1xi−1.

### Output Format

For each test case, output in a single line, the degree of the polynomial.

## Degree of Polynomial solution codechef

• 1T1001≤T≤100
• 1N10001≤N≤1000
• 1000Ai1000−1000≤Ai≤1000
• Ai0Ai≠0 for at least one (0i<N)(0≤i<N).Through this contest, selected students get access to a free 6 month LinkedIn Premium subscription which helps students:
• Discover & apply to 20M+ jobs/internships on LinkedIn
• Reach out to hiring managers/recruiters/mentors directly
• Find career paths that people similar to them have taken
• Learn from over 17K expert-led LinkedIn Learning courses (technical & soft-skills) with certificates

4
1
5
2
-3 3
3
0 0 5
4
1 2 4 0

0
1
2
2

## Degree of Polynomial solution codechef

Test case 11: There is only one term x0x0 with coefficient 55. Thus, we are given a constant polynomial and the degree is 00.

Test case 22: The polynomial is 3x0+3x1=3+3x−3⋅x0+3⋅x1=−3+3⋅x. Thus, the highest power of xx with non-zero coefficient is 11.

Test case 33: The polynomial is 0x0+0x1+5x2=0+0+5x20⋅x0+0⋅x1+5⋅x2=0+0+5⋅x2. Thus, the highest power of xx with non-zero coefficient is 22.

Test case 44: The polynomial is 1x0+2x1+4x2+0x3=1+2x+4x21⋅x0+2⋅x1+4⋅x2+0⋅x3=1+2⋅x+4⋅x2. Thus, the highest power of xx with non-zero coefficient is 22.