Reported August 2024
Salesforcegreedy

Least Hours

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

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

Salesforce threw Least Hours at candidates in August 2024, and it's a straightforward optimization problem that trips people up because they overthink the greedy choice. You've got a set of tasks with durations, and you need to minimize total time by picking the right order or strategy. The catch is that the greedy move isn't always obvious on first read. StealthCoder can spot the pattern instantly if you blank on the decision rule during the live assessment.

Pattern and pitfall

This is a classic greedy or math optimization problem. The trick is recognizing that you want to process tasks in a specific order to minimize idle time or cumulative wait. Most candidates default to sorting by duration, but Least Hours often rewards a different heuristic like earliest deadline, minimum gap, or a calculation that favors smaller numbers in a particular way. The algorithm is fast once you see it, but the insight is the barrier. If you freeze during the OA, StealthCoder reads the problem and gives you the winning order or formula without you typing a line of code yourself.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Least Hours 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Salesforce reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Least Hours FAQ

Is this a hard problem?+

No. It's medium at worst. The code is 5-10 lines once you know the sort order or formula. The hard part is the insight, not the implementation. Most people solve it in under 15 minutes.

Do I need dynamic programming or advanced structures?+

No. This is pure greedy or math. No DP, no heaps, no graphs. Sort the input and iterate. That's the pattern.

What's the trick I'm missing?+

You're probably sorting by duration ascending when you should be sorting by a different metric, or you're not recognizing that the problem is asking for a single optimal ordering, not a subset or schedule.

How do I prepare in 24 hours?+

Understand what 'hours' means in the problem context. Is it wall-clock time, cumulative wait, or something else. Once you nail the definition, the greedy move becomes obvious. Read three times.

Will Salesforce ask this pattern again?+

Yes. Greedy optimization and task scheduling are perennial at Salesforce. If you solve this one, you've seen the shape of their medium-difficulty OA questions.

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

OA at Salesforce?
Invisible during screen share
Get it