Question: Use java There are n gardens in a row. The gardens are numbered 1 to n and the i-th garden has a greenness of a[i],
Use java

There are n gardens in a row. The gardens are numbered 1 to n and the i-th garden has a greenness of a[i], with higher numbers representing greener gardens. Let us define the "greenness on the other side" for the owner of the i-th garden as the greenest garden besides the i-th garden. Create a program to enumerate all of the "greenness on the other side" for every garden in a row. Given the greenness of n gardens, please calculate the "greenness on the other side" for each garden.
Step by Step Solution
There are 3 Steps involved in it
A simple solution that iterates through the gardens and finds the greenest garden besides the curren... View full answer
Get step-by-step solutions from verified subject matter experts
