Data Structures19 sections · 729 units
Open in Course

Lessons from Distinct Values

summary

Important lessons:

1.1. Coordinate compression is often needed when values are large but the number of distinct values is small

2.2. The order of while loops in MO's matters: expand before shrinking to avoid negative range issues

3.3. Store the original query index to output answers in the correct order MO's algorithm works whenever you can efficiently add/remove single elements. What about problems where add/remove isn't O(1)O(1)?