Write a C program that finds all the leaders in an integer array.
An element is called a leader if it is strictly greater than all the elements to its right. The rightmost element is always considered a leader.
Example Inputs & Outputs:
Enter the number of elements: 6 Enter the elements: 16 17 4 3 5 2 Leaders: 17 5 2
Enter the number of elements: 5 Enter the elements: 1 2 3 4 5 Leaders: 5
Iterate from the end of the array and maintain a variable maxFromRight to track the maximum value encountered so far. Compare each element with maxFromRight and update it if the current element is a leader.
Optimize the solution to run in O(n) time.
Task: Write a program that implements this logic.