FastPrepFastest Kilometre Speed
Problems/Fastest Kilometre Speed

Fastest Kilometre Speed

Bank of America logoBank of America● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by an experienced software engineer who interviewed with Bank of America in Singapore. The report does not say which round gave the task; the process had a recruiter call, a technical phone call and a video interview. The task gave how far someone ran in every 5 seconds of a 10-kilometre race and asked for the best average pace, in metres per second, held across any single kilometre.

The report gives no input limits and no full example. Here, the run has at most 10,000 blocks, each block is at most 5,000 metres, the whole run is at most 100,000 metres, and we spell out how a block with no movement counts.

Our version is about 85% the same as the reported question.

Given distances, where distances[i] is the number of metres a runner covered in the i-th 5-second block of a run, return the fastest average speed, in metres per second, that the runner kept over any stretch of 1000 metres.

Inside a block the runner moves at a steady pace, so the moment the runner passes a point inside a block is found by linear interpolation. A stretch starts at a whole metre mark x and ends at x + 1000. Its time runs from the last moment the runner is at x to the first moment the runner reaches x + 1000, and its average speed is 1000 divided by that time.

One block may cover more than 1000 metres, and a block of 0 means the runner stood still. If the whole run is shorter than 1000 metres, return 0. Answers within 1% of the expected value are accepted.

Function

calculateFastestKilometreSpeed(distances: int[]) → double

Examples

Example 1

distances = [250,300,250,200,400]return = 57.14286

The best stretch is metre 400 to metre 1400. Metre 400 is halfway through the second block, passed at 7.5 seconds, and metre 1400 is reached at the end, at 25 seconds. That is 1000 / 17.5 = 57.14286 metres per second.

Example 2

distances = [1200]return = 240.0

The run is one block of 1200 metres in 5 seconds, a steady 240 metres per second, so every 1000-metre stretch has that average speed.

Example 3

distances = [500,0,600]return = 71.42857

The runner stands still for the whole second block. The best stretch is metre 100 to metre 1100: metre 100 is passed at 1 second and metre 1100 is reached at 15 seconds, so the speed is 1000 / 14 = 71.42857.

Example 4

distances = [300,300,300]return = 0.0

The whole run is only 900 metres, so there is no 1000-metre stretch and the answer is 0.

Constraints

  • 1 <= distances.length <= 10^4
  • 0 <= distances[i] <= 5000
  • The sum of all values in distances is at most 10^5.

More Bank of America interview questions

  • Return Exact Cash Register ChangeOA · Seen Aug 2026
  • Centered Star PyramidONSITE INTERVIEW · Seen Nov 2025
  • Employees Without a ManagerONSITE INTERVIEW · Seen Nov 2025
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2025
  • N-th Fibonacci NumberONSITE INTERVIEW · Seen Nov 2025
  • Reverse Each Word in a SentenceONSITE INTERVIEW · Seen Nov 2025
  • Second Highest SalaryONSITE INTERVIEW · Seen Nov 2025
  • Sum Skipping Multiples of 7OA · Seen Nov 2025
  • Wildcard Substring MatchOA · Seen Nov 2025
  • Three Numbers That Add Up to a TargetONSITE INTERVIEW · Seen Apr 2025

Similar questions at other companies

  • Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
  • Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Fill Missing Points on Line SegmentsDatadog · PHONE SCREENDatadog interview questions
  • Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
  • Paint the CeilingWeRide · OAWeRide interview questions
  • Paint the CeilingRoblox · OARoblox interview questions
  • Fastest Average Speed over a Rolling KilometerOptiver · OAOptiver interview questions
  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREENWhatNot interview questions
  • Interval List IntersectionsGrammarly · PHONE SCREEN

Bank of America interview experiences

  • Bank of America interviews · December 2025
  • Bank of America OA · December 2025
  • Bank of America interviews · September 2026
  • Bank of America OA · September 2026
All Bank of America interview questionsSee Bank of America hiring insights
Saved
class Solution {
    public double calculateFastestKilometreSpeed(int[] distances) {
        // write your code here
    }
}
Checking account…