Question: Need in python and O(n) for time and space complexity. Can someone explain please because using max() or min() in a for loop means O(n^2)
Need in python and O(n) for time and space complexity. Can someone explain please because using max() or min() in a for loop means O(n^2) does it not?

The Max of Minima: Your friend is looking to spend some days at a beautiful island resort during vacation. Help him select k continuous days ideal for the trip. Given an array representing the daily temperature throughout the vacation, find out k continuous days when the lowest temperature is at the maximum. Return the lowest temperature of the ideal days. Input: The input to the function/method has 3 arguments: -vacationDays, an int representing the total number of vacation days; -temperature, a list of ints representing the daily temperature during vacation, temperature[i] being the temperature of the ith day; -kDays Trip, an int representing the length of the trip to the island resort Output: Return an int representing the maximum lowest temperature possible in k continuous days. Constraints: 1 SkDays Trip s vacation Days 1s temperaturelil s 100 Osis kDays Trip Example: input: vacationDays = 8 temperature = [62, 64, 77, 75, 71, 60, 79, 75) kDays Trip = 4 Output: 64 Explanation: In this array of temperature, the subarrays of size 4 are [62, 64, 77, 75] and [64, 77, 75, 71], [77, 75, 71, 60], [75, 71, 60, 79), [71, 60, 79, 75), the minima are 62, 64, 60, 60, 60 among which 64 is the maximum. Therefore, the answer is 64
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
