Placement OA question help

Правка en1, от karanarjunjr, 2022-08-28 07:57:15

You are given an array $$$A$$$ of $$$N$$$ positive integers and you are allowed to construct new array $$$B$$$ in the following manner: Traverse $$$A$$$ from left to right and for each $$$i$$$ you can put $$$A_i$$$ either to the left or right of $$$B$$$ ($$$B$$$ is initially empty). You need to maximize the sum of all prefix XORs of $$$B$$$, that is, maximize $$$(B_1) + (B_1 xor B_2) + (B_1 xor B_2 xor B_3)...$$$

This question was asked in an online assessment for which one of my friends appeared. Both of us weren't able to solve it. Can someone please help me out?

Теги xor, prefix, placement, help

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский karanarjunjr 2022-08-28 08:08:13 41
en1 Английский karanarjunjr 2022-08-28 07:57:15 562 Initial revision (published)