Josephus Elimination Until Half Remain
Updated
Problem statement
People labeled 1 through n stand clockwise. The current person initially is 1. Advance k positions clockwise, not counting the current person; remove the person landed on. Resume from the next survivor.
Return removals in order, stopping when ceil(n/2) people remain.
Function
eliminateUntilHalf(n: int, k: int) → int[]Examples
Example 1
n = 6k = 4return = [5,4,6]Exclusive counting from 1 lands on 5; continue until three survivors remain.
Constraints
1 <= n <= 10^4.0 <= k <= 10^9.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- Evenly Schedule Vehicle InspectionsAmazon · PHONE SCREEN
- Implement Cross-Entropy LossOpenAI · PHONE SCREENOpenAI interview questions
- Cumulative No-Intercept Regression BetasCitadel · PHONE SCREENCitadel interview questions
- Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
- Automation Pipeline, Part 2: Stage WorkersPlaid · PHONE SCREENPlaid interview questions
- Reservoir Sampling with Recorded DrawsGoogle · PHONE SCREENGoogle interview questions
- Attention With Absolute Index BiasNVIDIA · PHONE SCREENNVIDIA interview questions
- K-Means Delivery ZonesDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
- Token Bucket Request DecisionsDatadog · PHONE SCREENDatadog 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)