Suppose I have a list of projects with start date and end date. I also have a range of weeks, which varies (could be over months, years, etc) I would like to display a graph showing 4 values per week:
- projects started
- projects closed
- total projects started
- total projects closed
I could loop over the range of weekly values, and for each week iterate through my list of projects and calculate values for each of these 4 trends per week. This would have algorithmic complexity O(nm)
, n
is the length of list of weeks, and m
is the length of projects list. That's not so great.
Is there a more efficient approach, and if so, what would it be?
If it's pertinent, I'm coding in Java