Leaders of the Array — Solution & Editorial
Scan from the right maintaining the running maximum; elements strictly above it (before updating) are leaders. Reverse the collected list.
Complexity: O(N)
Scan from the right maintaining the running maximum; elements strictly above it (before updating) are leaders. Reverse the collected list.
Complexity: O(N)