Zero To DSAZero To DSA
Privacy Policy
Quadratic vs Linear

Space Complexity Analysis

medium
Time: O(n)
Space: O(n)

What is the space complexity (excluding input) of this function?

Examples

Input: n = 5
Output: O(n)
A new array of size n is allocated.