Hyscaler processes numeric batches that require two independent results. Given an integer array and an inclusive upper bound, generate every prime number up to that bound, then identify the four largest values in the array and their sum.
Implement both computations efficiently. Duplicate array values must be counted separately. The four largest values must be returned in descending order. You may assume the array contains at least four integers.
Implement solve_tasks(nums, prime_limit).
nums, a list of integers, and prime_limit, a non-negative integer.primes: a list of all primes from 2 through prime_limit, in ascending order.top_four: the four largest values in nums, in descending order.sum: the sum of the values in top_four.Use the Sieve of Eratosthenes for prime generation. Do not sort the entire input array solely to obtain its largest four values.
def solve_tasks(nums, prime_limit):