Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I got an input array = [ 6 , 5 , 4 , 1 , 3 , 2 ] and I want the output to

I got an input array =[6,5,4,1,3,2] and I want the output to be [5,4,3,3,2]
Following the condition:
1. From each value in the array, one by one, if the left value is bigger than the right value, replace it with right value.
2. In case that the value is smaller than both left value and right value, replace the middle value with the minimum of left value and right value.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started