Company: Amazon_5nov

Difficulty: medium

Problem Statement

Maximum Performance Score Amazon Web Services runs data centres whose distributed databases are cut into blocks . Blocks are grouped into zones , and every zone is served by a fixed number of query slots. You are given an array blocks of n positive integers, where blocks[i] is the performance score of the i -th block, and two integers queryLimit and numZones . The blocks must be divided into exactly numZones consecutive, non-overlapping zones that together cover the whole array, and every zone must contain at least queryLimit blocks. The performance score of a zone is the sum of its queryLimit largest block values. For example, a zone holding [3, 6, 1, 8] with queryLimit = 2 scores 6 + 8 = 14 . The total system performance is the sum of the scores of all numZones zones. Choose the division that maximises the total, and print that maximum. Input Format Line 1: a single integer n , the number of blocks. Line 2: n space-separated integers blocks[0] ... blocks[n-1] . Line 3: a single integ

More Amazon_5nov OA questionsInterview experiences