Here is the problem statement and what I gather is the array to the right of any has to be less then or equal to the leader. In the example and in the test inputs it seems not to account for larger sums. Another Example is the input 17 4 3 5 2 4 still states the 17 is a leader when 4+3+5+2+4=18 which would be greater than making 17 no longer a leader. I'm just trying to understand what it's asking for in this practice problem.
You are given an array arr of positive integers. Your task is to find all the leaders in the array. An element is considered a leader if it is greater than or equal to all elements to its right. The rightmost element is always a leader.
Examples:
Input: arr = [16, 17, 4, 3, 5, 2]
Output: [17, 5, 2]
Explanation: Note that there is nothing greater on the right side of 17, 5 and, 2.
Input: arr = [10, 4, 2, 4, 1]
Output: [10, 4, 4, 1]
Explanation: Note that both of the 4s are in output, as to be a leader an equal element is also allowed on the right. side