DEV Community

Discussion on: Advent of Code 2020 Solution Megathread - Day 15: Rambunctious Recitation

Collapse
 
shalvah profile image
Shalvah

You can use a map to store the numbers you've seen. Map lookup is O(1), compared to looking through a list (O(n)). The keys can be the numbers you've seen, the values the list of positions.

Collapse
 
kudostoy0u profile image
Kudos Beluga

Thank you for the suggestion! I'll try it!