class Solution {
    // Function to find the leaders in the array.
  public:
    vector<int> leaders(vector<int>& arr) {
        // Code here
        vector<int> res;
        
        int n= arr.size();
        
        int max_right = arr[n-1];
       
        res.push_back(max_right);
         
        for (int i = n-2 ; i>=0 ; i--){
            if(arr[i] >= max_right){
                max_right = arr[i];
                res.push_back(arr[i]);
            }
        }
        
        reverse(res.begin() , res.end());
        
        return res;
    }
};

https://takeuforward.org/array/top-array-interview-questions-structured-path-with-video-solutions

https://www.geeksforgeeks.org/problems/leaders-in-an-array-1587115620/1