Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Gru is a super-scientist living in Gotham city in the post-apocalyptic period AD 2098. Gru has a lot of Minions in his home. He invents

Gru is a super-scientist living in Gotham city in the post-apocalyptic period AD 2098. Gru has a lot of Minions in his home. He invents a time machine which will take these minions into 2020 in the Era of Covid-19. The time machine will allow Minions only based on the following conditions. Lets say N minions are having ages A= [a1, a2,,aN]. Inside the machine, a youngest minion can start handshaking with others at a time. After the handshake, their ages will be decremented by the age of the youngest minion. In this way, the age of minions can be updated. If all of their ages become 0s at the end of a fixed number of handshakes, then the time machine will take them to 2020 in the Era of Covid-19. Otherwise, the time machine will give each of the minions a punch in their faces. Lets say A = [1, 2, 1, 2, 2], after the 1st handshake operation their ages are decremented by one and then the array becomes [0, 1, 0, 1, 1]. If 2nd handshake then A=[0, 0, 0, 0, 0]. So the answer should be Yes for N=2 and the answer should be No for N=1. If A=[1, 2, 3, 4, 5] and N=4 then the answer should be No. If A=[1, 2, 3, 4, 5] and N=5 then the answer should be Yes. Given the ages of minions A you need to tell Gru whether they can make it to 2020 or not. Sample Test Cases: Input: 1 2 1 2 2 2 Output: Yes Input: 1 2 3 4 5 4 Output: No Input: 1 1 2 3 3 Output: Yes

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

5. Benchmark current training practices.

Answered: 1 week ago