Reported September 2024
Oraclegreedy

Create Largest Permutation

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

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

Oracle asked this in September 2024, and it's a pattern you can crack in minutes if you know the move. You're building the largest possible permutation by swapping elements. The trick isn't complex math or a crazy algorithm. It's greedy. You want the biggest numbers in the leftmost positions. If you blank on the exact constraint during the OA, StealthCoder reads the problem and feeds you the strategy in real time so you don't lose points on a fundamentals question.

Pattern and pitfall

The algorithm is straightforward greedy: iterate left to right, and at each position, find the largest unplaced number that hasn't been used yet, then swap it into that position. Some versions constrain the number of swaps you're allowed. If swaps are limited, you still greedily place the largest available number at each position until you run out of swaps. The pitfall candidates hit is overthinking. They try dynamic programming or assume you need to pre-sort the entire array. You don't. Just scan forward, grab the max, swap, and move on. The permutation builds itself. During a live OA, if the exact constraint isn't clear, StealthCoder can parse it and confirm whether you're optimizing for maximum value or maximum value with swap limits.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Create Largest Permutation 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Oracle reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Create Largest Permutation FAQ

Is this really just greedy left-to-right swaps?+

Yes. Find the largest number not yet placed, swap it to the current position, move to the next position. If there's a swap limit, stop when you hit it. No DP, no bit tricks. Just greedy placement.

What if swaps are limited or unbounded?+

If unbounded, you can always build the fully sorted descending permutation. If limited, you place the largest available numbers first and stop when out of swaps. The problem statement will tell you which case applies.

How do I avoid off-by-one errors on the scan for max?+

Track the index of the max as you scan from the current position forward. Once you find it, swap it into the current position. Don't re-scan. Move to the next position. One pass per index.

Does this pattern show up in other Oracle OAs?+

Greedy permutation/array construction is common in Oracle technical screens. This one is simpler than average. If you can solve this cleanly, you've got the pattern for harder variants.

How much time should I spend on this in the OA?+

Code it in 10-15 minutes if you recognize the greedy pattern immediately. Test with a small example first. If you're stuck on the exact rules, read the problem twice and ask yourself: do I want max value or max value under constraints?

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

OA at Oracle?
Invisible during screen share
Get it