Question: in left Nearest Greater Element Actions Screen You are given an integer array A of size N and an index idx. Find the distance from
in left
Nearest Greater Element
Actions
Screen
You are given an integer array of size and an index idx.
Find the distance from the element at idx to the nearest element on its left that is greater than it If there is no such element for the chosen index, return
Notes:
For example, for the array and idx the nearest greater element on the left for the element at index which is is and the distance is
idx follows based indexing.
Function description
Complete the distanceToGreaterLeft function in the editor below. It has the following parameters:
Name
N
INTEGER
INTEGER ARRAY
A
idx
INTEGER
Description
The size of array
The given array.
The index of the element of interest in
Console
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
