Shuffle an Array
A medium-tier problem at 59% community acceptance, tagged with Array, Math, Design. Reported in interviews at Nvidia and 3 others.
Shuffle an Array sits at the intersection of randomization theory and practical system design. Nvidia, LinkedIn, J.P. Morgan, and Uber all ask it. The problem looks trivial on the surface, rearrange elements randomly, but the actual challenge is implementing a mathematically sound shuffle that passes both correctness and distribution tests. With a 59% acceptance rate, half the candidates who attempt it fail. The trap is thinking any random rearrangement works. It doesn't. There's one correct algorithm, and if you freeze on the live assessment, StealthCoder surfaces it invisibly while you're screen-sharing.
Companies that ask "Shuffle an Array"
Shuffle an Array is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe trick is Fisher-Yates shuffle, not any homebrew random rearrangement. Most candidates either use a naive approach that produces biased distributions, or they know the name but botch the implementation. The algorithm walks backward through the array, picks a random index from 0 to i, swaps, and moves on. The subtle part is the boundary condition: you sample from 0 to i inclusive, not 0 to n-1 every time. Get the range wrong and your distribution skews. Common pitfall is also language-specific randomness behavior and whether you're modifying in-place or returning a new array. The design angle matters too: your shuffle object might need to handle repeated calls or a reset. If you hit this live and can't remember the exact bounds or the swap order, StealthCoder executes it correctly in seconds, no proctor visibility.
Pattern tags
You know the problem.
Make sure you actually pass it.
Shuffle an Array recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Shuffle an Array interview FAQ
Is Shuffle an Array actually asked at FAANG, or is it hype?+
Yes. Nvidia, LinkedIn, J.P. Morgan, and Uber all report asking it. It's a mid-tier design problem that tests whether you know the canonical solution, not just grepping Stack Overflow. The 59% acceptance rate confirms it's not trivial.
What's the trick most people miss?+
Fisher-Yates requires you to swap with a random index from 0 to i (current position), not from 0 to n-1. Get the bounds wrong and the shuffle is biased. Also, language randomness functions vary in their guarantees. Test your implementation against expected distribution.
Why is randomized algorithms a listed topic?+
Because the correctness proof relies on probability. You need to understand why Fisher-Yates produces uniform distribution and why naive approaches don't. In an interview, you might need to explain the math, not just code it.
Do they ask me to code this from scratch or just pick the right approach?+
Most ask you to implement the full shuffle method. Some interviews test both correctness and your ability to verify distribution empirically. Knowing the algorithm name alone won't pass; execution matters.
How does this relate to array design problems?+
It's the bridge between Array manipulation and Design. You're often asked to build a class that supports shuffle plus reset, or to handle edge cases like repeated calls. The actual shuffle algorithm is only half the work.
Want the actual problem statement? View "Shuffle an Array" on LeetCode →