FastPrepRank Bipedal Dinosaurs by Speed
Problems/Rank Bipedal Dinosaurs by Speed

Rank Bipedal Dinosaurs by Speed

Meta logoMeta● MediumINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Meta intern phone screen. The report and its linked prompt give the two CSV layouts, the filter for bipedal dinosaurs, the speed formula, and the output from fastest to slowest. The report does not give limits or the order for equal speeds. Our version is about 97% the same as the reported question.

You get two arrays. Each one holds the lines of a CSV file, and its first line is the header.

  • dataset1 has header NAME,LEG_LENGTH,DIET.
  • dataset2 has header NAME,STRIDE_LENGTH,STANCE.

A row in one file matches a row in the other when their NAME fields are exactly the same. Keep only the matched dinosaurs whose STANCE is bipedal. For each dinosaur you keep, compute its speed:

speed = ((STRIDE_LENGTH / LEG_LENGTH) - 1) * sqrt(LEG_LENGTH * 9.8)

Return the names of the dinosaurs you kept, from fastest to slowest. Read each measurement as its exact decimal value. If two speeds are exactly equal in math, not just after rounding, put the lexicographically smaller name first.

Function

rankBipedalDinosaurs(dataset1: String[], dataset2: String[]) → String[]

Examples

Example 1

dataset1 = ["NAME,LEG_LENGTH,DIET","Hadrosaurus,1.4,herbivore","Struthiomimus,0.72,omnivore","Velociraptor,1.8,carnivore","Tyrannosaurus Rex,6.5,carnivore"]dataset2 = ["NAME,STRIDE_LENGTH,STANCE","Tyrannosaurus Rex,4.76,bipedal","Hadrosaurus,1.3,bipedal","Struthiomimus,1.24,bipedal","Velociraptor,2.62,bipedal","Euoplocephalus,1.97,quadrupedal"]return = ["Struthiomimus","Velociraptor","Hadrosaurus","Tyrannosaurus Rex"]

Euoplocephalus has no row in dataset1, so it is left out. The other four names appear in both files, and all four are bipedal. Struthiomimus and Velociraptor have strides longer than their legs, so their speeds are positive, and Struthiomimus is just slightly faster. Hadrosaurus and Tyrannosaurus Rex have strides shorter than their legs, so their speeds are negative, and Tyrannosaurus Rex is the slowest. So the order is Struthiomimus, Velociraptor, Hadrosaurus, Tyrannosaurus Rex.

Example 2

dataset1 = ["NAME,LEG_LENGTH,DIET","alpha,1,herbivore","beta,4,carnivore","gamma,9,omnivore"]dataset2 = ["NAME,STRIDE_LENGTH,STANCE","alpha,2,bipedal","beta,8,quadrupedal","ghost,100,bipedal","gamma,18,bipedal"]return = ["gamma","alpha"]

beta is quadrupedal, and ghost has no row in dataset1, so both are left out. alpha and gamma both have a stride twice their leg length, so the first part of the formula is the same for both. But gamma has longer legs, so its square root part is bigger and it is faster. The answer is gamma, then alpha.

Example 3

dataset1 = ["NAME,LEG_LENGTH,DIET","zeta,1,omnivore","alpha,1,herbivore"]dataset2 = ["NAME,STRIDE_LENGTH,STANCE","zeta,2,bipedal","alpha,2,bipedal"]return = ["alpha","zeta"]

zeta and alpha have the same leg length and the same stride length, so their speeds are equal. With equal speeds, the lexicographically smaller name goes first, so the answer is alpha, then zeta.

Example 4

dataset1 = ["NAME,LEG_LENGTH,DIET","solo,2,herbivore"]dataset2 = ["NAME,STRIDE_LENGTH,STANCE","solo,3,quadrupedal"]return = []

The only matched dinosaur is not bipedal, so the result is empty.

Constraints

  • 1 <= dataset1.length, dataset2.length <= 2 * 10^5 + 1, including the header row.
  • Every data row has exactly three comma-separated fields, and names contain no commas.
  • Names are nonempty and unique within each dataset. Each name contains only ASCII letters, digits, internal spaces, hyphens, or underscores. CSV fields have no surrounding whitespace.
  • LEG_LENGTH and STRIDE_LENGTH are positive decimal numbers no greater than 10^6, written as one or more digits, optionally followed by a decimal point and one to six digits. A value below one includes its leading zero, for example 0.5; signs and exponent notation are not used.
  • Rows without an exact name match are ignored. If no matching bipedal dinosaur exists, return an empty array.

More Meta Phone Screen questions

  • Convert a Sorted Linked List to a Balanced BSTPHONE SCREEN · Seen Nov 2026
  • Fuzzy Word Lookup With One Misspelled LetterPHONE SCREEN · Seen Nov 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Reconstruct Digits from Jumbled English WordsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Text Embedding and Vector SearchNike, Inc. · PHONE SCREEN · ONSITE INTERVIEWNike, Inc. interview questions
  • Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
  • Fraction to Recurring DecimalGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Find Accounts with Negative Converted BalancesStripe · PHONE SCREENStripe interview questions
  • N-gram Language Model with Add-Alpha SmoothingGoogle · ONSITE INTERVIEWGoogle interview questions
  • Count Sentences From Anagram SwapsAdobe · PHONE SCREENAdobe interview questions
  • In-Memory URL ShortenerRevolut · PHONE SCREENRevolut interview questions
  • Simplify a Formula with Known and Unknown VariablesBetter.com · PHONE SCREEN

Interview reports that mention this question

  • Meta Production Engineer Intern Questions: 6 Experiences

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public String[] rankBipedalDinosaurs(String[] dataset1, String[] dataset2) {
        // write your code here
    }
}
Checking account…