Elements which have at-least two greater elements

Given an array of distinct integers A, find and return
all elements in array which have at-least two greater elements than themselves.

Note: The results should have the order in which they are present in the original array.



Input Format

The only argument given is the integer array A.

Output Format

Return the elements which have at-least two greater elements than themselves.

Constraints

3 <= length of the array <= 100000
-10^9 <= A[i] <= 10^9 

For Example

Input 1:
    A = [1, 2, 3, 4, 5]
Output 1:
    [1, 2, 3]

Input 2:
    A = [5, 17, 100, 11]
Output 2:
    [5, 11]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Elements which have at-least two greater elements on Interview Code Editor
Hints
  • Hints are not available for this problem

Discussion


Loading...
Click here to start solving coding interview questions