verition fund management金融公司OA(求大米)

avatar 206051
pbking1
3301
1
冒死贴题,跪求大米他们公司主要写c++,这个oa可以用c++, java, c#写

Sample a TimeSeries
Allotted time: 1.5 HourWe have a TimeSeries class, which is just 2 parallel vectors of 1)time in microseconds since midnight, and 2) values.template class TimeSeries{ std::vector timeUsSinceMid; std::vector values;}
Your job is to write a "sample()" as a member function for TimeSeries,and return a new TimeSeries.Sample() takes 2 parameters - frequency, and an optional starttime. Frequency is how often you want to sample, in microseconds. AndstartTime is defined to be when sampling begins. The output timeserieswill conceptually be a series of samples.
A sample would be the time ofthis particular sample, plus the value at or before that time in theoriginal time series.
The start time may be before or after timeUsSinceMid[0], or the firsttime in the original time series.
If you don't supply the startTimeargument, it is implied to be equal to the first element of youroriginal time series.
If startTime is set before this timeSeriesstarts, it would fast forward until the first valid startTime.(e.g. if the original timeSeries starts 9:00:01, and we want to samplewith frequency of 30 seconds, with startTime at 9:00:00, then you'dfast forward to first valid startTime, or 9:00:30.)
C++ TimeSeries * sample(uint64_t sampleFreq, uint64_t startTime = 0);Java public TimeSeries sample(long sampleFreq, long startTime);
C# public TimeSeries Sample(long frequency, long startTime = 0)
For example, say you are given the following time series.09:00:00 A09:01:00 B09:02:00 C09:03:00 D09:04:00 ESo the original time series starts at 9:00:00. And say you aresampling at 60 seconds.
The result should be09:00:00 A09:01:00 B09:02:00 C09:03:00 D09:04:00 EBut if you are sampling at 30 seconds, the result would look like09:00:00 A09:00:30 A09:01:00 B09:01:30 B09:02:00 C09:02:30 C09:03:00 D09:03:30 D09:04:00 E
Note that I have time printed out in human readable format just forthe purpose of explaining this problem.
In your code, time will besimply an unsigned 64 bit int (c++) or long (Java, C#)
Assumptions- the input time series will have times that are between 0 and 24 hours- the input times will be an increasing, non repeating, sequence of numbers. So eg. it could be 1 2 3 4 5 or 1 10 11 12 100
  • 3
1条回复