Pressure Chamber Linear Interpolation
Updated
Problem statement
Pressure Chamber Linear Interpolation
A pressure chamber must follow target pressures as a vehicle's velocity changes during liftoff. The task provides known velocity-to-pressure points and asks for the target pressure at another velocity without introducing a sudden jump.
Function Contract
For this exercise, assume velocities and pressures describe aligned known points. The velocities are strictly increasing, and queryVelocity lies between the first and last known velocities, inclusive.
If queryVelocity equals a known velocity, return its pressure. Otherwise, find the two neighboring known velocities and return the pressure obtained by linear interpolation between their aligned pressure values.
Function
interpolateChamberPressure(velocities: double[], pressures: double[], queryVelocity: double) → doubleExamples
Example 1
velocities = [0.0,100.0]pressures = [120.0,300.0]queryVelocity = 50.0return = 210.050 is halfway between velocities 0 and 100, so its pressure is halfway between 120 and 300: 210.
Example 2
velocities = [0.0,25.0,70.0]pressures = [100.0,150.0,330.0]queryVelocity = 25.0return = 150.0The query exactly matches the second known velocity, so return its aligned pressure 150.
Example 3
velocities = [0.0,20.0,50.0]pressures = [100.0,140.0,200.0]queryVelocity = 35.0return = 170.035 is halfway between 20 and 50, so interpolate halfway between pressures 140 and 200.
Constraints
2 ≤ velocities.length == pressures.length ≤ 100,000- All input values are finite doubles with absolute value at most
10^9. velocitiesis strictly increasing.velocities[0] ≤ queryVelocity ≤ velocities[velocities.length - 1]- Answers within
10^-6of the exact interpolated pressure are accepted.
More SpaceX interview questions
- Starlink Beam PlannerOA · PHONE SCREEN · Seen Nov 2026
- Timestamped Telemetry Stream DifferencesPHONE SCREEN · Seen Sep 2026
- Number of IslandsPHONE SCREEN · Seen Aug 2026
- Number of Islands IIPHONE SCREEN · Seen Aug 2026
- Button Combination DetectorPHONE SCREEN · Seen Feb 2026
- Speed to Pressure LookupPHONE SCREEN · Seen Mar 2025
- Simplified Time-Based Key-Value StorePHONE SCREEN · Seen Nov 2023
- Rocket Component CostONSITE INTERVIEW · Seen Aug 2025
- DNA Sequence MatchOA · Seen Apr 2025
- Find the Duplicate NumberONSITE INTERVIEW · Seen Jan 2021
Similar questions at other companies
- Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Minimum of a Convex FunctionRippling · PHONE SCREENRippling interview questions
- Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
- Percentile and Boundary QueriesDatadog · PHONE SCREENDatadog interview questions
- Floor Square Roots for an ArrayWells Fargo · OAWells Fargo interview questions
- Maximum Alloy Production Within BudgetMicrosoft · OAMicrosoft interview questions
- Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
- Koko Eating BananasTekion · ONSITE INTERVIEWTekion interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
- Koko Eating BananasAmazon · ONSITE INTERVIEW