DEV Community

Cover image for IBM OA Interview Experience Two Questions, Finished in About 20 Minutes
interviewshow-cs
interviewshow-cs

Posted on

IBM OA Interview Experience Two Questions, Finished in About 20 Minutes

Honestly, this IBM OA was pretty low-pressure.

The question style was straightforward—no unusual algorithms or tricky concepts. It mainly tested whether you could read the rules carefully and handle the edge cases correctly. There were two questions in total: one involving a greedy approach with a heap, and the other focused on grouped simulation. I didn't really get stuck on either one.

That said, there were two details worth knowing in advance:

  • Q1: The rental price is based on the current remaining inventory, not the original inventory. It's easy to misread this the first time.
  • Q2: The multiplication and addition sequence needs to follow the parentheses exactly. It may look obvious, but it's surprisingly easy to reverse the order when implementing it.

Q1: Total Revenue from VM Rentals

You are given n types of virtual machines, each with a certain amount of inventory. There are m customers arriving one by one.

Each customer always rents the VM type with the largest current remaining inventory. The rental price equals the number of machines remaining at that exact moment. After a machine is rented, the inventory for that type decreases by 1.

Return the total revenue.

Example:

Inventory: [1, 2, 4]
m = 4

Revenue:
4 + 3 + 2 + 2 = 11

Approach

The most straightforward solution is a max heap.

  1. Put all inventory values into a max heap.
  2. Remove the current maximum value.
  3. Add that value to the total revenue.
  4. Decrease it by 1.
  5. If the remaining inventory is still greater than 0, push it back into the heap.
  6. Repeat until m customers have rented a VM or the inventory is completely exhausted.

Important edge case: If m is larger than the total inventory, stop once the heap becomes empty. Don't keep looping and accidentally count rentals that cannot happen.

The time complexity is O(m log n).


Q2: Odd and Even Index Group Operations

Split the array into two groups:

  • Elements at even indices
  • Elements at odd indices

For each group, perform operations from left to right using the specified alternating pattern:

multiply → add → multiply → add → ...

After calculating both groups, take each result modulo 2.

  • If the odd-index group produces the larger result → ODD
  • If the even-index group produces the larger result → EVEN
  • If both results are equal → NEUTRAL

Example:

[12, 3, 5, 7, 13, 12]

Both groups produce 1 after the final calculation,
so the answer is:

NEUTRAL

The Main Trap

The operation order matters a lot. Don't rely on intuition—follow the parentheses and the expression in the original problem statement exactly.

After implementing the solution, manually walk through the sample once. This is the kind of problem where the general idea can be completely correct while a single reversed operation causes the wrong answer.

Since only the final result modulo 2 matters, you can apply modulo 2 throughout the calculation instead of dealing with potentially large numbers.


IBM Interview Process: Quick Overview

Stage Typical Format
Online Assessment HackerRank, around 60–90 minutes, usually 2–3 questions
Recruiter Call 15–30 minutes, background discussion and Why IBM
Technical Interviews 1–2 rounds, Coding + project discussion, with SQL often carrying more weight
Behavioral Interview STAR-style questions about teamwork, disagreements, and project delays
Overall Timeline Roughly 4–8 weeks, usually moving at a relatively slow pace

A Few Preparation Notes

  • The OA itself isn't particularly difficult. The bigger risk is spending too much time on problems you already know how to solve. If you're comfortable with the heap pattern, Q1 can be finished very quickly.
  • Prepare for a deep dive into your projects. Be ready to explain your architecture decisions, bottlenecks, testing methods, and what you would change if you had to rebuild the project.
  • Three or four solid behavioral stories are usually enough. In my experience, IBM's follow-up questions were generally less aggressive than Amazon's, so clear and authentic examples matter more than memorizing a huge number of stories.

FAQ

Q1: Why not simply sort the inventory?

Because the inventory changes after every rental. The original maximum decreases by 1, which means it may no longer remain the largest value.

A max heap lets you efficiently maintain the current maximum after every update. Re-sorting the entire array after each rental would be much less efficient.

Q2: Is it valid to take modulo 2 during every step?

Yes. Both addition and multiplication preserve modular arithmetic, so applying mod 2 during the calculation produces the same final result as applying it only at the end.


Final Thoughts

If you're preparing for an IBM OA or other North American tech company assessments, it can help to focus on common patterns such as greedy heap problems, string manipulation, hashing, and simulation.

For candidates who want more targeted practice, InterviewShow provides interview preparation support, including personalized problem walkthroughs and targeted practice for common technical interview patterns.

Good luck with your OA!

Top comments (0)