I am working on a CodeEval problem called Working Experience.
I am given input in the form of "Month Year-Month Year" as ranges of time that someone has worked. The goal is to calculate the total time worked, however overlaps do not count, such that if the range Jan 2014-Dec 2014 appeared twice, the total time worked would still only be 12 months (1 year).
Due to the input constraints, The dates are in range [Jan 1990, Dec 2020]. The end date > begin date. I believe I can force myself to an answer, but it doesn't exactly satisfy me for obvious reasons.
Set of input would look like:
Aug 2013-Mar 2014; Apr 2013-Aug 2013; Jun 2014-Aug 2015; Apr 2003-Nov 2004; Apr 2014-Jan 2015
Extremely forced solution: Make a boolean array that represents the months from Jan 1990 to Dec 2020. Easy to handle overlaps, just trigger flag changes if a range contains a specific month. Sum up the number of "trues" or something at the end.
I am trying to implement my solution in Java, it seems that quite a few people have done this problem in Python however I am unfamiliar with it, so I not even too clear on their algorithmic approach in their solution.
I have not worked with Date, Time, Calendars and whatnot much in Java. So I am unsure if any of these would be of any help to me. I think I am having the most issue dealing with overlaps and how to overcome them.