TopCoder problem "CalcBusinessDays" used in SRM 26 (Division I Level Two , Division II Level Two)



Problem Statement

    
Class name: CalcBusinessDays
Method name: calcBusinessDays
Parameters: String, String, String[]
Returns: int


You are part of a team working on a management information system.  Management
would like to know how well the customer service area is doing.  One of the
measures management would like to track is the request turnaround.


The request turnaround is a measure of how quickly a request was completed and
is calculated by determining the number of business days between when the
request was placed (start date) and when it was completed (end date).  A
business day is defined as any working day (does not include Saturday, Sunday
or any Holidays).


Implement a class CalcBusinessDays, which contains a method calcBusinessDays.
The method returns the sum of the business days between a start date
(exclusive) and an end date (inclusive) and does not include days listed in the
holiday schedule.


The method signature is (Be sure your method is public):
int calcBusinessDays(String startDate, String endDate, String[] holidays);


*All dates will have the format of "mm/dd/yyyy"
*All dates will be between (inclusive) "01/01/1990" and "12/31/2002"
*All dates will be valid (ie "02/29/2001" will not be allowed)
*The startDate cannot fall on a Saturday, Sunday or Holiday.
*The endDate will be greater than or equal to the startDate and may fall on a
Saturday, Sunday or Holiday.
*The holiday list will contain from 0 to 50 holidays, inclusive.


Note:
-If the endDate is equal to the startDate, the task was accomplished on the
same day and the turnaround is 0.
-The endDate can be a non-business day
-Remember the number of days within each month
{31,28,31,30,31,30,31,31,30,31,30,31}.  February will have 29 days in leap
years (those years divisible by 4 within our valid range above)


Examples:
-If the start date is "07/30/2001" (Monday) and the end date is "08/03/2001"
(Friday) with no intervening holidays, the turnaround is 4.


-If the start date is "07/30/2001" (Monday) and the end date is "08/03/2001"
(Friday) with a holiday on "08/01/2001", the turnaround is 3.


-If the start date is "08/03/2001" (Friday) and the end date is "08/04/2001"
(Saturday), the turnaround will be 0 (holidays are irrelevant here)


-If the start date is "08/27/2001" (Monday) and the end date is "09/03/2001"
(Monday) with no intervening holidays, the turnaround is 5.

-If the start date is "12/31/1999" (Friday) and the end date is "01/01/2001"
(Monday) with no intervening holidays, the turnaround is 261.

-If the start date is " 02/28/2000" (Monday) and the end date is "03/01/2000"
(Wednesday) with no intervening holidays, the turnaround is 2.

 

Definition

    
Class:CalcBusinessDays
Method:calcBusinessDays
Parameters:String, String, String[]
Returns:int
Method signature:int calcBusinessDays(String param0, String param1, String[] param2)
(be sure your method is public)
    

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=151

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=3025&pm=151

Writer:

Pops

Testers:

Problem categories: