Whenever you're ready, walk me through how you'd approach this.
Explain how you use SQL features like MIN/MAX, window functions, and joins, and how you use Python dictionaries to map IDs and maintain running counts.