Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TERRAFORM This question accounts for 5 0 % of the total test. Please do not forget to submit your answer, timed out tests will result

TERRAFORM
This question accounts for 50% of the total test. Please do not forget to submit your answer, timed out tests will result in 0 points awarded.
Your family recently bought exoplanet TRAPPIST1E from the Annual Planet Auctions and gave a region of the planet to you. To your surprise, the region you were given was a rocky mountain range A of M mountains with heights Hi...Hm.
You decided to terraform the region to make it look exactly like a mountain range B of M mountains with heights G|..G.
For mountain range A to look exactly like B, if array H = array G
You have access to an infinite supply of explosives that can reduce the height of any mountain by 1 per explosion. The bomb can only be dropped in between consecutive mountains, hence both mountains will have their neights decrease by 1 per explosion.
Determine the minimum number of explosions required to make
mountain range A look exactly like b, or return -1 it it's not possibleCONSTRAINTS.1= M 4=105005=HA <=109
0<= G <=109
INPUT SPECIFICATIONS
*input1: the number of mountains in the mountain range, M
*input2:- the heights of mountain range A, Hi...Hm
*input3:- the heights of mountain range B, G|...Gm
OUTPUT SPECIFICATIONS
output:- integer denoting the minimum number of explosions needed
EXAMPLE
Given
*M=3
*H =(2,3,21}
*H =(2,3,21
*G =11,1,1}
After explosion between Oth and 1st index,
H =11,2,2)
After explosion between 1st and 2nd index.
H =(1,1,1}
Now H = G
Therefore the minimum number of explosions required should be
2.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

Are shares freely transferable? Explain.

Answered: 1 week ago

Question

2. Eve really enjoys the science center.

Answered: 1 week ago

Question

Describe the linkages between HRM and strategy formulation. page 74

Answered: 1 week ago

Question

Identify approaches to improving retention rates.

Answered: 1 week ago