Company: Microsoft_5march
Difficulty: medium
Maximum Bitwise OR-Sum Problem Description You are given an array arr of n positive integers and an integer k . You may perform the following operation at most k times: pick any index i ( 0 <= i < n ) and replace arr[i] with arr[i] * 2 . The same index may be picked any number of times, and you may stop before using all k operations. The or-sum of an array is the bitwise OR of all of its elements. Find the largest or-sum the array can have after your operations. Function Description Complete the function getMaxOrSum . getMaxOrSum has the following parameters: arr : the original array of integers. k : the maximum number of operations. It returns the maximum possible or-sum as a 64-bit integer ( long ). Input Format The first line contains the integer n , the size of arr . Each of the next n lines contains one element arr[i] . The last line contains the integer k . Output Format Print the maximum possible or-sum on a single line. Examples Example 1 Input: 2 12 9 1 Output: 30 Explan