Time to test your Big O skills! In this challenge, you'll analyze multiple code snippets and determine both their time AND space complexity.
# Snippet A
def snippet_a(arr):
seen = set()
for num in arr:
if num in seen:
return True
seen.add(num)
return False
# Snippet B
def snippet_b(n):
if n <= 1:
return n
return snippet_b(n-1) + snippet_b(n-2)
# Snippet C
def snippet_c(arr):
arr.sort()
return arr[0]
📋 Instructions
For each snippet (A, B, C), determine the **time** and **space** complexity.
Print your analysis in this exact format:
```
A: Time=O(n) Space=O(n)
B: Time=O(2^n) Space=O(n)
C: Time=O(n log n) Space=O(1)
```
**Hint about Snippet B:** It's recursive Fibonacci — each call branches into 2 more calls. The call stack depth is n.
A: The loop runs n times (O(n) time) and the set can hold up to n items (O(n) space). B: Recursive Fibonacci has exponential time O(2^n) and the call stack goes n deep O(n) space. C: Python's sort is O(n log n) time and sorts in-place so O(1) extra space.