Implement polynomial multiplication API in C
Company: NVIDIA
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency in C programming, API design, low-level data representation for polynomials, and algorithmic competence in performing coefficient convolution while handling edge cases like differing degrees, zero and negative coefficients.
Constraints
- coefficients are integers
- Trailing zero coefficients are trimmed except for the zero polynomial
Examples
Input: ([5, -2, 0, 1], [4, 2, 1])
Expected Output: [20, 2, 1, 2, 2, 1]
Explanation: Example-style cubic times quadratic.
Input: ([1, 2], [3, 4, 5])
Expected Output: [3, 10, 13, 10]
Explanation: Different degrees.
Input: ([0], [1, 2, 3])
Expected Output: [0]
Explanation: Zero polynomial trims to [0].
Input: ([-1, 1], [-1, 1])
Expected Output: [1, -2, 1]
Explanation: Negative coefficients.
Hints
- Use coefficient convolution: result[i+j] += p[i] * q[j].