Uber: Astroid collision
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2017-10-30Added By Anonymous
Source: Link
Company: Uber
Role: unknown
Interview Stage: unknown
Location: unknown
Year: unknown
Original Post Content:
Given input array of astroid size and its direction (left:positive or right:negative), find out what will be the result or remaining astroid after their collision.
Example 1] Astroid: {-6, 4, 10,}
-6: Astroid of size 6 pound moving in direction right.
4: Astroid of size 4 pound moving in direction left.
-6 will collide with 4 and results in {-6, 10}
-6 collide with 10 and results in {10}
Ans: {10}
Example 2] Astroid: {10, -8, 15,}
10 will collide with -8 and results in {10, 15}
Ans: {10,15} as both traveling to left direction.