Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started