Minimum Steps with Double and Floor-Divide
Updated
Problem statement
Given target, return the fewest steps needed to reach it, starting with the integer 1.
Each step replaces the current value x with either:
x * 2, orfloor(x / 3), which divides and rounds down to an integer.
Function
minStepsToTarget(target: int) → intExamples
Example 1
target = 1return = 0The starting value already equals the target.
Example 2
target = 5return = 5One shortest sequence is 1 -> 2 -> 4 -> 8 -> 16 -> 5.
Example 3
target = 3return = 7A shortest sequence is 1 -> 2 -> 4 -> 8 -> 16 -> 32 -> 10 -> 3.
Constraints
0 <= target <= 100- All intermediate values are represented with signed 64-bit integers.
- Every target in the allowed range is reachable.
More Bloomberg LP Onsite Interview questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Count Reachable Values by Halving and DecrementingInfosys · OAInfosys interview questions
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Shortest Pin Path Through TopicsPinterest · PHONE SCREENPinterest interview questions
- Integers With Multiple Sum of Two CubesCharta Health · PHONE SCREEN · ONSITE INTERVIEWCharta Health interview questions
- Word Chain Jumps in a GridGoogle · PHONE SCREENGoogle interview questions
- Currency Conversion RateAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Hierarchical Permission CheckeBay · ONSITE INTERVIEWeBay interview questions
- Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
- Group Identical Tree LevelsSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Filter Paginated Medical RecordsNVIDIA · PHONE SCREENNVIDIA interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)