Alexa is Amazon's virtual Al assistant. It makes it easy to set up your Alexa-enabled devices, listen to music, get weat

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Alexa is Amazon's virtual Al assistant. It makes it easy to set up your Alexa-enabled devices, listen to music, get weat

Post by answerhappygod »

Alexa Is Amazon S Virtual Al Assistant It Makes It Easy To Set Up Your Alexa Enabled Devices Listen To Music Get Weat 1
Alexa Is Amazon S Virtual Al Assistant It Makes It Easy To Set Up Your Alexa Enabled Devices Listen To Music Get Weat 1 (192.18 KiB) Viewed 30 times
Alexa is Amazon's virtual Al assistant. It makes it easy to set up your Alexa-enabled devices, listen to music, get weather updates, and much more. The team is working on a new feature that suggests days for camping based on the weather forecast. According to a survey, a day is ideal for camping if the amount of rainfall has been non-increasing for the prior kdays from the considered day, and will be non-decreasing for the following k days from the considered day. Given the predicted rainfall for the next n days, find all the ideal days. Formally, the day iis ideal if the following is true: day[i-k] ≥ day[i-k+1] ≥ .... ≥ day[i-1] ≥ day ≤ day[i+1] ≤.... ≤ day[i+k-1] ≤ day[i+k] Return the array of ideal days in ascending order. Note that the ith element of the array represents the data for the day i+ 1. It is guaranteed that the there is at least one ideal day. Example day = [3, 2, 2, 2, 3, 4] k = 2 For a day to be ideal, the amount of rainfall has to be non-increasing for the prior 2 days and non-decreasing for the following 2 days. Example day = [3, 2, 2, 2, 3, 4] k = 2 For a day to be ideal, the amount of rainfall has to be non-increasing for the prior 2 days and non-decreasing for the following 2 days. 2 From the above diagram: • The rainfall trend for day3 is day1 ≥ day2 ≥ day3 ≤ day4 ≤ day5 so day 3 is ideal. • The rainfall trend for day4 is day2≥ day3≥ day4 ≤ day5 ≤ day6 so da y4 is ideal. The answer is [3, 4]. Function Description Complete the function predictDays in the editor below. predictDays has the following parameters: int day[n]: predicted rainfall for each day k: an integer Returns int[]: the ideal days, sorted ascending Constraints • 1≤ksn≤2.105 0 ≤day ≤ 10⁹ ▼ Input Format For Custom Testing The first line contains an integer, n, the number of elements in day. Each of the next n lines contains an integer, day, where 0<i<n. The last line contains an integer, k. ▾ Sample Case 0 Sample Input For Custom Testing STDIN FUNCTION 5 day [] size n = 5 day = [1, 0, 1, 0, 1] 1 0 1 0 1 1 k = 1 Sample Output 2 4 Explanation The following days are ideal: • day1 ≥ day2 ≤ day3 day3≥ day4≤ day5 ➜
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply