# HackerRank Coding Interview 8. Maximum Or-Sum

Time to complete — 30 minutes

Question Type = Medium

Asked in = Netflix, Amazon, Uber, Lyft, Bloomberg, Morgan Stanley, Apple, and Google, Synchrony.

Skills: arrays, bit manipulation, prefix array

# Question —

For an array of n integers, arr[n], perform the following operation up to some integer k times.

• Choose an index i such that 1 ≤ in.
• Replace arr[i] with arr[i]×2.

The or-sum is the bitwise-or of all elements in the final array after the operations. Return the maximum or-sum possible.

`# HINT is below# bitwise operators a = 10b = 4 # Print bitwise AND operationprint("a & b =", a & b) # Print bitwise OR operationprint("a | b =", a | b) # Print bitwise NOT operationprint("~a =", ~a) # print bitwise XOR operationprint("a ^ b =", a ^ b)`
`HINT .....for Bitwise OR operation with integer 2 .....K-times, is nothing but RIGHT shift the number K times.Interger_value << k ==== K-times [Interger_value (bitwise-OR) 2 ]`

Example

arr = [12, 9]

k = 1

These outcomes are possible after 1 operation.

1. Select i = 1 :

--

--

I am Executive Data Science Manager. Interested in Deep Learning, LLM, Startup, AI-Influencer, Technical stuff, Interviews and much more!!!