I would do something like:
- create a map to hold the data
- read in a pair
- For i = pair.first to pair.second ++map[i]
- if there are more pairs, repeat from 2
- Find the element in the map with the largest count. The key for that element is the year.
In theory, you could use a vector instead of a map, but it’s probably going to be sparsely enough populated that a map makes more sense.
0
solved largest number of dinosaurs that were ever alive [duplicate]