Let's test your knowledge. Click the correct answer from the options.
What is the time complexity of the below brute force solution?
1def stockOptimizer(prices):
2	maxDiff = 0
3	for i in range(len(prices)):
4		for j in range(len(prices)):
5			newDiff = prices[j] - prices[i]
6
7			if newDiff > maxDiff:
8				maxDiff = newDiff
9
10	return maxDiff
11
12print(stockOptimizer([2, 5, 15, 9]))Click the option that best answers the question.
- O(n)
- O(n^2)
- O(n^3)
- O(1)
OUTPUT
Results will appear here.