Sorting, Greedy & Binary Search
IBM prompts rarely say "sort," but sorting is behind a fair share of the assessment. One prompt might ask for the largest team whose skill levels are close together. Another might want a day of transactions ordered so the balance stays positive for as long as possible. In both, sorting first turns a question about every possible subset or ordering into one pass over a sorted list. Intervals, sorting and greedy choices together are roughly an eighth of IBM's coding, on the same HackerRank test as the arrays.
Two of the problems are about the sort itself. One needs a key whose tiebreak runs the other way, and one sorts pieces of a string while the boundaries between those pieces stay put. Two more use sorting as setup, one with a run counter and one with a greedy running total. The last is a binary search with no target value, where the sorted order the prompt gives you is the only hint.
IBMPremium lesson · Coding round
The 5 IBM problems are below.
- A Premium questionCoding · Easy · Frequently asked
- A Premium questionCoding · Medium
- A Premium questionCoding · Medium
+ 2 more in this lesson
Each with hints, the follow-up and a tested solution.
Get the IBM questions$49 a year · all 100 companies · cancel anytime
From 328 IBM reports, forum threads behind logins and write-ups in Chinese.
IBM interview guideKnow what IBM asks before you walk in.
30 coding · 3 system design · 13 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.