Reported March 2024
General Motorsbinary search

Smallest But Greater

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

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

You're facing General Motors' 'Smallest But Greater' question in March 2024, and it's a classic binary search or tree traversal trap. The candidate reports mention no explicit pattern, which means you need to infer fast. The problem is asking you to find the smallest value that's larger than a target in some collection. This is the kind of question where the naive approach gets you 40% of test cases, and StealthCoder becomes your safety net if the optimal structure doesn't click in the first 90 seconds.

Pattern and pitfall

This problem almost certainly involves a sorted structure (array, BST, or sorted map) where you're hunting for the next-largest element. The trick is that you can't just scan linearly. You need binary search or BST in-order traversal to hit the time constraint. Common pitfall: candidates iterate through everything, miss the sorted assumption, or forget edge cases like 'target doesn't exist' or 'target is the maximum'. The pattern is binary search or tree-based lookup. If you're staring at an unsorted input, you'll sort first. When you're live and stuck on the search logic, StealthCoder reads the problem fresh and surfaces the exact boundary condition you're missing.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Smallest But Greater 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 would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

General Motors reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Smallest But Greater FAQ

What if the target value isn't in the collection?+

You still find the smallest value that's strictly greater than the target. Binary search with modified logic finds the leftmost position where insertion would preserve order, then return that element if it exists.

Is this a BST problem or array search?+

Could be either. If input is a BST, in-order traversal plus a counter or pointer works. If it's an array, sort it first, then binary search. The company doesn't change the pattern.

What's the time complexity they're expecting?+

O(log n) for a sorted structure, O(n log n) if you have to sort first. Linear scans get marked down unless n is tiny. General Motors asks for optimized code.

What happens if every value is smaller than the target?+

Return null, -1, or empty, depending on the spec. Read the problem statement carefully. This is where 10% of submissions fail.

Can I prepare this in 48 hours?+

Yes. Practice binary search on a sorted array and BST in-order traversal on LeetCode. Both are 20-minute drills. The real test is staying calm under pressure and catching edge cases.

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

OA at General Motors?
Invisible during screen share
Get it