Leaders in Array Problem
Leaders in Array Problem — ExecCode School DSA Practice
Solve the Leaders in Array problem on ExecCode. Free online school DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given a whole number for the problem Leaders in Array. Your task is to solve Leaders in Array. Find all elements in an array that are greater than every element to their right. The rightmost element is always considered a leader.
Examples
Input 6 16 17 4 3 5 2; Output 17 5 2. Input 5 1 2 3 4 0; Output 4 0
Constraints
1<=N<=10^5
Practice Leaders in Array free on ExecCode. Browse DSA problems, topic map, and placement guides.