FastPrepAsteroid Collision
Problems/Asteroid Collision

Asteroid Collision

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in Bloomberg new grad onsite interviews. They name this well-known problem exactly. Our version is about 100% the same as the reported question.

You are given an integer array asteroids representing asteroids in a row. The absolute value is an asteroid's size, and its sign is its direction: positive moves right and negative moves left. All asteroids move at the same speed.

When two asteroids moving toward each other collide, the smaller one explodes. If their sizes are equal, both explode. Asteroids moving in the same direction never collide.

Return the asteroids that remain after every collision, in their original left-to-right order.

Function

asteroidCollision(asteroids: int[]) → int[]

Examples

Example 1

asteroids = [5,10,-5]return = [5,10]

The asteroid 10 destroys -5; asteroid 5 never meets another left-moving asteroid.

Example 2

asteroids = [8,-8]return = []

The two approaching asteroids have equal size, so both explode.

Example 3

asteroids = [10,2,-5]return = [10]

Asteroid -5 first destroys 2, then asteroid 10 destroys -5.

Constraints

  • 1 <= asteroids.length <= 10^5.
  • -10^9 <= asteroids[i] <= 10^9.
  • asteroids[i] != 0.

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

  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Fountain SafetyGoogle · ONSITE INTERVIEWGoogle interview questions
  • Trace Events from Stable Whole-Stack StatesAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Surviving Balls after Directional CollisionsSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Render a Comment HierarchyAmazon · ONSITE INTERVIEW
  • Asteroid CollisionAdobe · ONSITE INTERVIEWAdobe interview questions
  • Most Frequent Call Path in Interleaved LogsRoblox · ONSITE INTERVIEWRoblox interview questions
  • Asteroid CollisionZscaler · ONSITE INTERVIEWZscaler interview questions
  • Exclusive Time of FunctionsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Implement Stack Push and Pop OperationsLSEG · ONSITE INTERVIEWLSEG 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)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[] asteroidCollision(int[] asteroids) {
        // write your code here
    }
}
Checking account…