Problem Statement: There are $n$ hours in a day and you have $w$ workers. For each worker $i$ you will be given $x_i$ (work experience), $s_i$ (shift start time) and $e_i$ (shift end time) on a separate line. Here $s_i$ and $e_i$ are both inclusive. At any given hour $t$ in a day, you have to determine who is the most experienced worker available.
I thought of two approaches:
Keep an interval array of size $n$. For each worker $i$, from index $s_i$ to $e_i$ of the array, fill it with $x_i$ if current value in the array is lesser. This is memory intensive.
Store $\left( x_i, s_i, e_i \right)$ for each worker $i$ in a list. Loop through the list for every $t$ provided to find the most experienced person. This is CPU intensive.
I want to know which data structure can be used to solve this problem optimally.