Problem Statement | |||||||||||||
| Moving averages are well known in stock charts analysis.
They are used to emphasize the direction of a trend and to smooth out fluctuations.
Athletes may use moving averages to analyze their training results.
Given a String[] times containing the times from successive training sessions (e.g. the time to cycle a certain leg) and an int n, return a int[] containing the n-moving averages in seconds for these times, with each average rounded down. Each element of times is in the format "hh:mm:ss" (quotes for clarity), where hh, mm and ss are two digit numbers (with a leading zero if necessary) indicating the number of hours, minutes and seconds, respectively. A n-moving average is the average (i.e. the arithmetic mean) of n consecutive times. So for t times given, t-n+1 n-moving averages are to be calculated. The first average is composed from the times 1 to n, the second average from the times 2 to n+1 and so on, the last average is composed from the times t-n+1 to t. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
| - | times contains between 1 and 50 elements, inclusive. | ||||||||||||
| - | Each element of times is in the format "hh:mm:ss" (quotes for clarity), where hh is a two digit number (with a leading zero if necessary) between 0 and 23, inclusive, mm is a two digit number (with a leading zero if necessary) between 0 and 59, inclusive, ss is a two digit number (with a leading zero if necessary) between 0 and 59, inclusive. | ||||||||||||
| - | n is between 1 and the number of elements in times, inclusive. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||