FastPrepRoad Trip (Analyst Program :P
Problems/Road Trip (Analyst Program :P

Road Trip (Analyst Program :P

BlackRock logoBlackRock● EasyFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

You've decided to make a road trip across the country in a straight line. You have chosen the direction you'd like to travel and made a list of cities in that direction that have gas stations to stop at and fill up your tank. To make sure that this route is viable, you need to know the distances between the adjacent cities in order to be able to travel this distance on a single tank of gasoline. (No one likes running out of gas.) but you only know distances to each city from your starting point.

Input:

Your program should read lines from standard input. Each line contains the list of cities and distances to them, comma-delimited, from the starting point of your trip. You start your trip at point 0. The cities with their distances are separated by semicolon.

Output:

Print out the distance from the starting point to the nearest city, and the distances between two nearest cities separated by comma, in order they appear on the route.

˚𖤣 𖥧‧⚘ ❀༉˚Credit to chizzy_elect 🌷

Function

calculateDistance(input: String) → String

Examples

Example 1

input = "Rkbs, 5453; Wdqiz, 1245; Rwds, 3890; Ujma, 5589; Tbzmo, 1303;"return = "1245, 58, 2587, 1563, 136"

Will add once find reference :P

Constraints

  • 🍑🍑

More BlackRock interview questions

  • Find Minimum TimeOA · Seen Nov 2026
  • Count LevelsOA · Seen Sep 2026
  • Valid ParenthesesOA · Seen Sep 2026
  • Lowest Common Ancestor in a Parent TreeOA · Seen Sep 2026
  • Set IntersectionOA · Seen Aug 2026
  • Process SchedulingPHONE SCREEN · Seen Mar 2026
  • John Venn (Analyst Program :)OA · Seen Sep 2024
  • Corporate LadderOA · Seen Jul 2024
  • Happy NumberOA · Seen Jul 2024

Similar questions at other companies

  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Find a File in a Directory SnapshotCresta · OACresta interview questions
  • Flat JSON Value DifferencesChubb · OAChubb interview questions
  • Get Search ResultsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Lexicographic Word FrequenciesUpstart · OAUpstart interview questions
  • Email Log Processing, Grouping, and SortingStripe · OAStripe interview questions
  • Most Frequent CharacterMicrosoft · OAMicrosoft interview questions
  • Get Maximum Information GainAmazon · OA
All BlackRock interview questionsSee BlackRock hiring insights
Saved
class Solution {
    public String calculateDistance(String input) {
      // write your code here
    }

}
Checking account…