IBM 2026 OA write-up | BI / Architecture related role | HackerRank, 75 minutes, 2 questions
Sharing the IBM HackerRank OA I did recently.
- Role: BI / Architecture
- Platform: HackerRank
- Duration: 75 minutes
- Number of questions: 2
- Language: any
Both are algorithm questions, no SQL. The first one is about simulating objects colliding, the second is about math and optimizing modulo operations.
Question 1: Objects Moving on a Table
Problem description:
You are given a table of length tableLength with n objects on it, each with an initial position and a velocity.
The input is three parameters:
- position: the initial position of each object
- velocity: the velocity of each object
- tableLength: the length of the table
A positive velocity means moving right, a negative velocity means moving left. When two objects collide, they swap velocities. Once an object leaves the edge of the table it is removed. All objects start moving at the same time at t=0.
Task: compute the time at which the last object leaves the table, rounded up.
Example:
tableLength = 9
position = [2, 4, 5]
velocity = [2, -2, 4]
Output: 4
Explanation:
The first object starts at position 2 and moves right at speed 2, the second starts at position 4 and moves left at speed 2. They collide at position 3 at t=0.5 and swap velocities. The times at which the three objects finally leave the table are:
- Object 1: 2 seconds
- Object 2: 3.5 seconds
- Object 3: 1 second
The last object leaves at 3.5 seconds, rounded up to 4.
Constraints:
1 <= n <= 2 * 10^5
2 <= tableLength <= 10^9
0 < position[i] < tableLength
-10^9 <= velocity[i] <= 10^9
velocity[i] != 0
Approach:
You don't need to actually simulate the collisions. Since two objects swap velocities when they collide, it is equivalent to them passing straight through each other and carrying on (if you don't care which object is which). So you only need to compute, for each object, the time it takes to reach the edge moving at its initial velocity:
- positive velocity: (tableLength - position[i]) / velocity[i]
- negative velocity: position[i] / abs(velocity[i])
Take the maximum of all those times, then round up.
Time Complexity: O(n)
Space Complexity: O(1)
Question 2: Checksum Aggregation
Problem description:
In a distributed network system there are n data packets, with identifiers 1 to n. For any two packets i and j, the checksum is defined as:
C(i, j) = i % j + j % i
Compute the sum of the checksums over all (i, j) pairs, where:
1 <= i <= n
1 <= j <= n
Note that both (i, j) and (j, i) are counted, and i = j is included. The final result is taken modulo 10^9 + 7.
Function:
computeChecksumAggregation(n)
Example 1:
Input: n = 2
C(1,1) = 0
C(1,2) = 1
C(2,1) = 1
C(2,2) = 0
Output: 2
Example 2:
Input: n = 3
All pairs:
C(1,1) = 0
C(1,2) = 1
C(1,3) = 1
C(2,1) = 1
C(2,2) = 0
C(2,3) = 3
C(3,1) = 1
C(3,2) = 3
C(3,3) = 0
Output: 10
Example 3:
Input: n = 4
Output: 24
Constraints:
1 <= n <= 10^6
Approach:
The most direct way is a double for loop:
for i in range(1, n + 1):
for j in range(1, n + 1):
total += i % j + j % i
But that is O(n^2), and since n can be up to 10^6 it will time out. You need to use some math to optimize it.
Because:
C(i,j) = C(j,i)
C(i,i) = 0
you can consider only the i < j case and multiply by 2 at the end.
When i < j:
i % j = i
so the sum can be split into two parts:
S = 2 * sum(i + j % i), for all i < j
The first part can be computed directly with the arithmetic series formula.
The second part uses the periodicity of the modulo operation. For a fixed i, let:
q = n // i
r = n % i
then the sum of the remainders can be computed from the full periods plus the leftover part, without iterating over every j.
In the end the time complexity can be brought down to O(n).
Time Complexity: O(n)
Space Complexity: O(1)
Summary
For this IBM BI / Architecture related role, both OA questions were Python-style algorithm problems. No SQL, Pandas, or BI knowledge was tested.
The first question mainly tests whether you can spot the equivalence of swapping velocities on collision, so you can avoid a complicated physics simulation.
The second question mainly tests math derivation and optimizing algorithm complexity; using nested loops directly will time out.
Overall I felt the second question was harder than the first, especially since you have to derive the modulo sum formula yourself.
Hope this helps anyone preparing for the IBM OA!
Discussion
Loading comments…