Dehydrated Strawberry
Updated
Problem statement
A strawberry weighs initialMass grams, and initialWaterPercent percent of that weight is water. It is left out to dry. Only water leaves the strawberry, and when it is done, water makes up finalWaterPercent percent of its weight.
Return the new weight of the strawberry in grams.
Answers within 10-6 of the correct value are accepted.
Function
strawberryMass(initialMass: int, initialWaterPercent: int, finalWaterPercent: int) → doubleExamples
Example 1
initialMass = 100initialWaterPercent = 99finalWaterPercent = 98return = 50.0Water is 99% of 100 grams, so the rest of the strawberry weighs 1 gram. Drying does not change that gram. After drying, water is 98%, so the 1 gram is 2% of the new mass. The new mass is 1 / 0.02 = 50 grams.
Example 2
initialMass = 200initialWaterPercent = 90finalWaterPercent = 80return = 100.0The dry part is 10% of 200, which is 20 grams. After drying it is 20% of the mass, so the mass is 20 / 0.2 = 100 grams.
Example 3
initialMass = 10initialWaterPercent = 60finalWaterPercent = 25return = 5.333333333The dry part is 40% of 10, which is 4 grams. After drying it is 75% of the mass, so the mass is 4 / 0.75 = 5.333... grams.
Example 4
initialMass = 100initialWaterPercent = 50finalWaterPercent = 0return = 50.0The dry part is 50 grams. With 0% water left, the strawberry is only its dry part, so it weighs 50 grams.
Constraints
1 <= initialMass <= 1060 <= finalWaterPercent < initialWaterPercent <= 99
More Jane Street Phone Screen questions
- Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
- Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
- Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
- Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
- Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
- Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
- Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
- Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
- Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
- Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
Similar questions at other companies
- Sqrt(x)LinkedIn · PHONE SCREENLinkedIn interview questions
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Circular Primes Below a LimitAmazon · PHONE SCREEN
- Palindrome NumberKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
- Streaming AverageXantium · PHONE SCREEN
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
Interview reports that mention this question
- Jane Street TDOE US Final Round: 11 Experiences (Part 5 of 10)
- Jane Street TDOE UK Phone Screen: 15 Experiences (Part 4 of 10)
- Jane Street TDOE UK Coding Round: 15 Experiences (Part 3 of 10)
- Jane Street TDOE Interviews: 165 Experiences (Part 1 of 10)
- Jane Street TDOE US Phone Screen: 20 Experiences (Part 6 of 10)
- Jane Street TDOE New Grad Interview Questions: 11 Experiences