🎁 Exclusive Offer! Join our
Telegram Channel
to get **special discounts** and updates! 🚀
Question 68 - 100% Working Solution | Buy Now
Description
7 Live
FindMaximumWeights
Amazon's fulfillment centers handle packages of various weights, and they need to optimize their sorting process.
Given an array weight that denotes the weights of n packages, the goal is to create the lexicographically maximal resulting array sorted in non-increasing order using the following operations:
1. Discard the first package from the current weight array.
2. Add the first element to the resulting array, then remove it along with the next k (a fixed constant) elements from the current array.
Operation 2 can also be applied when fewer than k elements remain after the current element; in that case, the entire remaining array is removed.
The resulting array must have packages arranged in non-increasing weight order.
Given an array weight of size n and an integer k, find the lexicographically maximal resulting array sorted by non-increasing order of weight that can be obtained.