Next Permutation
A medium-tier problem at 43% community acceptance, tagged with Array, Two Pointers. Reported in interviews at Nike and 32 others.
Next Permutation shows up at Meta, J.P. Morgan, Nike, and Bloomberg regularly enough that you can't skip it. The problem looks simple on the surface: rearrange an array into its lexicographically next permutation in-place. But the acceptance rate sits at 43%, which means most candidates who haven't drilled the pattern either timeout with brute force or lock up on the algorithm itself. If you hit this during a live OA and blank on the two-pointer trick, StealthCoder solves it invisibly while you stay calm.
Companies that ask "Next Permutation"
Next Permutation 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. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe trap is thinking you need to generate all permutations or use recursion. The real solution is a three-step greedy scan: find the rightmost position where the array dips (where arr[i] < arr[i+1]), find the smallest element to the right that's larger than that position, swap them, and reverse the suffix. It's pure Array and Two Pointers work, no fancy data structures. Most candidates waste time on the wrong direction or forget to reverse the tail. That's where the acceptance rate craters. The pattern is deterministic once you see it, but 'seeing it' under interview pressure without prior exposure is the blocker. StealthCoder is the safety net if the pattern doesn't click in the first two minutes.
Pattern tags
You know the problem.
Make sure you actually pass it.
Next Permutation 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. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Next Permutation interview FAQ
Is Next Permutation actually asked at FAANG?+
Yes. Meta, Bloomberg, and JP Morgan all have it on record. It's one of those medium-difficulty array problems that passes as a screening question because it tests pattern recognition and two-pointer technique under time pressure. Acceptance data shows it's real, not a rare outlier.
Why is the acceptance rate so low if it's just two pointers?+
Because the two-pointer logic is hidden. Candidates either brute-force permutations (TLE), get the direction backwards, or forget the reverse step. The trick isn't obvious without the pattern. Once you've seen it or practiced it, it clicks. First time blind, most people don't finish.
What's the actual trick that separates AC from TLE?+
Scan right-to-left to find the first position where arr[i] < arr[i+1]. If none exists, you're at the last permutation, so reverse the whole array. Otherwise, find the smallest element to the right of that position that's larger than arr[i], swap, and reverse the suffix. It's O(n) time, O(1) space.
How does Next Permutation relate to Array interview prep?+
It's a core test of in-place manipulation and two-pointer technique. If you can solve this, you've got the fundamentals for rotate array, reverse subarray problems, and partition logic. It's a signal that you understand index manipulation under constraints.
Should I memorize the solution or understand the pattern?+
Understand the pattern. The three-step scan is logical once you see it. Memorizing the code will fail under live pressure if the interviewer asks a variation. Drill the mindset: find the dip, find the swap target, reverse the tail.
Want the actual problem statement? View "Next Permutation" on LeetCode →