Company: ibm_10sep
Difficulty: medium
Largest Repackaged Packet Problem Description A stream of packets arrives at a video player that can only play packets of size 2 n units (where n is a non-negative integer). All packets are repackaged to the largest possible value of 2 n units. Any remaining units from a packet are added to the next arriving packet before it is repackaged. Given an array of arriving packet sizes, find the size of the largest repackaged packet. Function Signature: long largestRepackaged(vector<int> arrivingPackets) { // Complete the function } The function is expected to return a LONG_INTEGER. The function accepts INTEGER_ARRAY arrivingPackets as parameter. Input Format: The first line contains an integer, n , the size of arrivingPackets[] . Each line i of the n subsequent lines (where 0 ≤ i < n ) contains an integer, arrivingPackets[i] . Examples Example 1: Input: arrivingPackets = [13, 25, 12, 2, 8] Output: 16 Explanation: First packet (13 units): Current total = 13. The largest 2 n ≤ 1