Reported November 2025
Accenturearray

Array Leader Elements

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

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

The Accenture Array Leader Elements question, reported in November 2025, looks like a warm-up, and that's the trap. The naive version checks every element against everything to its right, and with up to 10^5 values that's a timeout waiting to happen. The other trap is equal values, since the first 7 in [7,7,3] is not a leader. This is a clean array problem with a one-pass fix. If you blank on the strictness rule mid-assessment, StealthCoder can sit invisibly on your screen and hand you the solution live. Know the trick first, though. It takes five minutes.

The problem

Given an integer array nums, return every leader element in its original left-to-right order.
An element nums[i] is a leader when it is strictly greater than every element to its right. The final element is always a leader because no elements follow it.
If equal values occur, an earlier value is not a leader when the same value appears to its right.

Function
findLeaders(nums: int[]) → int[]

Examples
Example 1
nums = [16,17,4,3,5,2]
return = [17,5,2]
17 is greater than every value after it. The same is true for 5 and the final value 2. Each other value has a larger value somewhere to its right.
Example 2
nums = [9,7,5,3]
return = [9,7,5,3]
The array is strictly decreasing, so every value is greater than all values to its right.
Example 3
nums = [7,7,3]
return = [7,3]
The first 7 is not strictly greater than the equal 7 to its right. The second 7 and the final value 3 are leaders.

Constraints
1 <= nums.length <= 10^5
-10^9 <= nums[i] <= 10^9

Reported by candidates. Source: FastPrep

Pattern and pitfall

Scan from right to left and track the maximum seen so far. The last element is always a leader, so start there. For each earlier element, if it's strictly greater than the running max, it's a leader, and you update the max. Otherwise skip it. That's O(n) time and O(1) extra space beyond the output. The pitfall is the comparison. Use strictly greater, not greater-or-equal, or [7,7,3] returns [7,7,3] instead of [7,3]. The second pitfall is order. You collect leaders right to left, so reverse the result before returning, or the output won't match the original left-to-right order. Initialize the max to negative infinity, not 0, because values go down to -10^9. If you freeze on any of these during the live OA, StealthCoder is the hedge that covers you without the proctor seeing anything.

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 Array Leader Elements 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 Accenture's OA.

Accenture 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.

Array Leader Elements FAQ

How hard is the Accenture Array Leader Elements problem really?+

It's easy once you see the right-to-left scan. The brute force is O(n^2) and fails at 10^5 elements, but the fix is a single loop with one variable. Most candidates lose points on the strictness rule or the output order, not the algorithm.

What's the trick to solving it fast?+

Walk the array from the end and keep the largest value seen so far. An element is a leader only if it's strictly greater than that max. Add it to the result, update the max, and reverse the list at the end.

How do equal values change the answer?+

An element must be strictly greater than everything to its right. In [7,7,3], the first 7 loses because an equal 7 sits to its right. Use a strict greater-than comparison against the running max and you handle it automatically.

What edge cases should I test before submitting?+

Test a single-element array, which returns itself. Test a strictly decreasing array, where everything is a leader. Test all equal values, where only the last one counts. Test all negatives, which catches a bad max initialization of 0.

How do I prepare for this in 48 hours?+

Write the right-to-left scan from memory twice, then run the three examples by hand. Practice the reverse step and the strict comparison. That covers the whole problem. Spend the rest of your time on other array and suffix-max patterns, since this question is a small version of that family.

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

OA at Accenture?
Invisible during screen share
Get it