Reported August 2024
IBMstring

Get Smallest String

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 'Get Smallest String' hit the assessment circuit in August 2024 and it's a string manipulation problem that looks simpler than it is. You're building the lexicographically smallest string from some operation or constraint, and the trap is thinking greedy works when you actually need to backtrack or think about character ordering. StealthCoder reads the exact constraint in real time, so if you blank on whether you can swap, delete, or rearrange, you have a safety net.

Pattern and pitfall

The pattern here is string manipulation with a greedy or constructive twist. Most candidates assume they can build the answer left-to-right, but IBM's version likely requires you to either reverse-engineer the smallest result by working backward, or carefully choose which characters to keep and in what order. The trick is understanding the operation's constraint: can you only remove characters, swap adjacent ones, or pick from a pool. Common mistake is not realizing you might need to defer a smaller character to avoid getting stuck with larger ones. StealthCoder will show you the exact rules when you see the problem live, letting you spot the pattern immediately instead of wasting five minutes on a wrong approach.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Get Smallest String 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as smallest subsequence of distinct characters. If you have time before the OA, drill that.

⏵ The honest play

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

IBM reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Get Smallest String FAQ

Is this a simple greedy problem or does it need DP or backtracking?+

The reported version suggests greedy won't cut it. You likely need to either backtrack to explore removing different characters, or use a stack-based approach to manage character ordering. The smallest result often means sacrificing early wins for better ones later.

What's the most common mistake candidates make on this one?+

Building the answer left-to-right without looking ahead. If you commit to keeping a character too early, you might block yourself from placing a smaller one later. Test with 'dcba' vs 'abcd' logic in your head first.

Do I need to know a specific algorithm or is this just careful coding?+

It's careful coding plus pattern recognition. Likely involves a monotonic stack or a two-pass scan. The key is knowing whether to process forward, backward, or with a deferred decision structure. That's where recognizing the pattern fast matters.

How do I prepare for this in 48 hours if I've never seen it?+

Practice building the lexicographically smallest string from an array or by removing k characters. Understand stack-based approaches to maintaining order. Then run through edge cases: empty input, all same characters, reversed alphabetical order.

Will IBM ask follow-ups about time or space complexity?+

Likely. Aim for O(n) time if possible. If you use a stack or extra string, space is O(n) but often acceptable. Be ready to explain why your approach doesn't revisit characters unnecessarily.

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