Posted by: donald_duck April 15, 2014
Any programmer geeks to help?
Login in to Rate this Post:     0       ?        
I am in software development profession for quite a while.
When I interview programmers I give this question as a part of screening. It might be helpful to new programmers who are seeking placement. Thanks for good thoughts.

Here you go.
When a car breaks, it is sent to the car repair shop, which is capable of repairing at most CountPerDay cars per day. Given a record of the number of cars that arrive at the shop each morning, your task is to determine how many days the shop must operate to repair all the cars, not counting any days the shop spends entirely workless.

For example, suppose the shop is capable of repairing at most 8 cars per day, and over a stretch of 5 days, it receives 10, 0, 0, 4, and 20 cars, respectively. The shop would operate on days 1 and 2, sit idle on day 3, and operate again on days 4 through 7. In total, the shop would operate for 6 days to repair all the cars.

Write a class CarRepairs containing a method GetDays that takes a sequence of In-coming counts InComing(of type int[]) and an int CountPerDay, and calculates the number of days of operation.

Definition
Class: CarRepairs
Method: GetDays
Parameters: int[], int

Method signature: int GetDays (int[] InComing, int CountPerDay )
Returns: int

Conditions:
-InComing contains between 1 and 20 elements, inclusive.
-Each element of InComing is between 0 and 100, inclusive.
-CountPerDay is between 1 and 50, inclusive.
 
Last edited: 15-Apr-14 11:04 AM
Read Full Discussion Thread for this article