Question: solve this code in python Task 03 [10 Points ]: Somewhere in the universe, the Biannual Regional Alien Competition is taking place. There are N

 solve this code in python Task 03 [10 Points ]: Somewhere

in the universe, the Biannual Regional Alien Competition is taking place. There

solve this code in python

Task 03 [10 Points ]: Somewhere in the universe, the Biannual Regional Alien Competition is taking place. There are N aliens standing in a line. You will be given a permutation of N, which denotes the height of each alien. A sequence of N numbers is called permutation if it contains all integers from 1 to N exactly once. For example, the sequences [3,1,4,2],[1] and [2,1] are permutations, but [1,2,1],[0,1] and [1,3,4] - are not. In the competition, for each alien, the judge wants to count how many aliens are standing on its right side with a strictly smaller height. The judge writes the following code to solve the problem. count =0 for i in range (n): for j in range (i+1,n): if H[i]>H[j]: count+=1 However, their algorithm wasn't efficient at all. Hence, the alien calls you to write a better solution for the program. More formally, you have to count how many pairs of aliens are standing in the line such that H[i]>H[j] and i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!