Data Structures19 sections · 729 units
Open in Course

Lessons from Daily Temperatures

Index tracking

What did you learn?

1.1. When you need distances instead of values, store indices on the stack.

2.2. The monotonic property still applies: compare values at indices, but push/pop indices.

3.3. Elements left on the stack (cooler than everything after) get 00 automatically because the array was initialized to zeros. You'll handle a harder problem that uses this pattern in a more subtle way.