Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Strugacarro is a planet whose year is divided into four seasons: winter, spring, summer and autumn in that order. A year has N days


image text in transcribed
image text in transcribed

Strugacarro is a planet whose year is divided into four seasons: winter, spring, summer and autumn in that order. A year has N days and every season lasts for exactly N/4 days. The year starts on the first day of winter and ends on the last day of autumn. Given the history of temperatures from the previous year, find the season with the highest amplitude of temperatures. The amplitude is the difference between the highest and lowest temperatures over the given period. Assume that all seasons within one year have different temperature amplitudes. Write a function: class Solution { public String solution (int[] T); } that, given an array T of N integers denoting the temperatures on all days of the year, returns a string with the name of the season with the highest temperature amplitude (one of the following: "WINTER", "SPRING", "SUMMER", "AUTUMN"). For example, given T = [-3, -14, -5, 7, 8, 42, 8, 3]: -5 -3-14 578 42 83 WINTER SPRING SUMMER AUTUMN the function should return "SUMMER", since the highest amplitude (34) occurs in summer. For example, given T = [-3, -14, -5, 7, 8, 42, 8, 3]: -3-14 -578 42 8 3 WINTER SPRING SUMMER AUTUMN the function should return "SUMMER", since the highest amplitude (34) occurs in summer. Given T = [2,-3, 3, 1, 10, 8, 2, 5, 13, -5, 3, -18]: 2-3 31 10 WINTER 25 8 2 5 13 -5 3-18 SPRING SUMMER AUTUMN the correct answer is "AUTUMN" (amplitude equals 21). Assume that: The number of elements in the array is divisible by 4; each element of array T is an integer within the range [-1,000..1,000]; N is an integer within the range [8..200]; Amplitudes of all seasons are distinct. In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.

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

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

Students also viewed these Programming questions

Question

Review the findings of humanistic psychotherapy outcome research.

Answered: 1 week ago