FastPrepLast Object Exit Time
Problems/Last Object Exit Time

Last Object Exit Time

IBM logoIBM● MediumINTERNFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IBM intern online assessment. The report crops out the last rows of the worked example and does not show general limits on the numbers. Our version is about 96% the same as the reported question.

Special thanks: 🌷 A special thank you to a lovely, amazing fren for sharing that a similar version of this question appeared again on November 20, 2026! (∩˃o˂∩)♡ 💜

Several objects move along a table represented by the line segment from 0 to tableLength. For object i, position[i] is its distinct starting coordinate and velocity[i] is its nonzero signed velocity.

  • A positive velocity moves an object to the right.
  • A negative velocity moves an object to the left.
  • All objects start moving simultaneously at time 0.
  • When two objects collide, they instantly exchange velocities.
  • An object leaves the table after crossing either boundary.

Return the ceiling of the time when the final object leaves the table.

Function

lastObjectExitTime(tableLength: int, position: int[], velocity: int[]) → int

Examples

Example 1

tableLength = 9position = [2,4,5]velocity = [2,-2,4]return = 4

Because equal-mass collisions exchange velocities, the set of paths is equivalent to the objects passing through one another. Their independent exit times are 7/2, 4/2, and 4/4 seconds. The maximum is 3.5, whose ceiling is 4.

Constraints

  • tableLength > 0.
  • position.length == velocity.length and at least one object is present.
  • Every position[i] is strictly between 0 and tableLength.
  • No two objects have the same starting position.
  • Every velocity[i] is nonzero.
  • Collisions occur instantly.

More IBM Online Assessment questions

  • Missing IntervalsOA · Seen Nov 2026
  • Count Peaks and ValleysOA · Seen Nov 2026
  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
  • Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
  • Tree Pythagorean TriplesOA · Seen Oct 2026
  • Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
  • Maximum Compatible Time WindowsOA · Seen Oct 2026
  • Query Type Frequency WindowOA · Seen Oct 2026

Similar questions at other companies

  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Bold Play to Reach a GoalSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Find Total CostJP Morgan Chase · OAJP Morgan Chase interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Daily Settlement for Long and Short PositionsBelvedere Trading · OA
  • Debug the Risk-Limit QuoterMillennium · OAMillennium interview questions
  • Prime Factor VisitationMaven Securities · OAMaven Securities interview questions
  • Proportional Momentum Investment StatisticsOptiver · OAOptiver interview questions

Interview reports that mention this question

  • IBM Full-Time SWE OA Questions: 1 Experience

IBM interview experiences

  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public int lastObjectExitTime(int tableLength, int[] position, int[] velocity) {
        // Write your code here
    }
}
Checking account…