What does the optimized scan track?
Practice this question from Best Time to Buy and Sell Stock - Greedy Pattern Practice Quiz, with options and an explanation.
Question
What does the optimized scan track?
Option A
Maximum price seen so far only
Option B — Correct answer
Minimum price seen so far and best profit
Option C
All previous profits in a list
Option D
A hash map of day to price
Explanation
It tracks the lowest price seen so far and the best profit so far.