neerajnanvani / PracticeGitAndJs

Its an practice repo to create pull request and use more github features
0 stars 10 forks source link

solution of Leader in an array - Nagesh Singh #72

Open NageshSingh-VidyaMantra opened 1 year ago

NageshSingh-VidyaMantra commented 1 year ago

Q2: Leaders in an array

Given an array A of positive integers. Your task is to find the leaders in the array. An element of array is leader if it is greater than or equal to all the elements to its right side. The rightmost element is always a leader.

Input & Output:

Input: n = 6 A[] = {16,17,4,3,5,2} Output: 17 5 2 Explanation: The first leader is 17 as it is greater than all the elements to its right. Similarly, the next leader is 5. The right most element is always a leader so it is also included.

close #73