Reported September 2024
IBMcounting

Max Index

Reported by candidates from IBM's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live IBM OA. Under 2s to a working solution.
Founder's read

IBM's Max Index question hits you in September OAs, and it's deceptively simple on the surface. You read the problem, think you've got it in 30 seconds, then realize the edge cases will wreck you if you're not careful. The pattern is straightforward: find the index of the maximum element in an array. But the devil is in the details, whether that's handling ties, dealing with negative numbers, or understanding what "max index" actually means in their test cases. StealthCoder sits in the corner of your screen during the live OA, ready to catch the gotcha you might miss under pressure.

Pattern and pitfall

Max Index is fundamentally a linear scan problem. You iterate through the array once, track the maximum value and its index, and return. Time complexity is O(n), space is O(1). The trick isn't the algorithm, it's the spec. Do they want the first occurrence of the max, or the last. What if the array is empty, all negatives, or has only one element. Many candidates code the happy path and fail hidden test cases. The pattern is counting and array traversal. When you're live in the OA and your solution passes the visible test but you're not confident about edge cases, StealthCoder can verify the approach or suggest the fix in seconds, so you don't burn time second-guessing yourself.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Max Index cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass IBM's OA.

IBM reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Max Index FAQ

What's the actual trick in Max Index?+

There isn't a complex algorithmic trick. It's about reading the spec carefully. Most failures come from not knowing whether they want the first max index, the last, or something else. Read the problem statement twice before coding.

Do I need to sort or use extra space?+

No. Single pass, O(n) time, O(1) space. Sorting would be overkill and waste time. Stay disciplined. Just one loop, one max tracker, one index tracker.

What about empty arrays or all negative numbers?+

These are common edge cases IBM tests. If the array is empty, you might return -1 or null depending on the spec. All negatives still works fine: you find the least negative. Clarify these in the problem statement before you code.

How do I prepare for this in 24 hours?+

You don't need to. Write out the algorithm on paper, trace through an example, list the edge cases (empty, single element, all same, ties). Test your code mentally. That's enough. Confidence beats cramming.

Is this pattern still asked at IBM in 2024?+

Yes, as of September 2024. Simple doesn't mean it's gone out of style. IBM uses it because it's fast to evaluate and people still mess up the details. Expect to see it.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with IBM.

OA at IBM?
Invisible during screen share
Get it