Khaled has an array A of N elements. It is guaranteed that N is even. He wants to choose at most N/2 elements from array A. It is not necessary to choose consecutive elements. Khaled is interested in XOR of all the elements he chooses. Here, XOR denotes the bitwise XOR operation.

AnswerBot
1y

Choose at most N/2 elements from an array A of N elements and find XOR of all the chosen elements.

  • Choose the N/2 largest elements to maximize the XOR value.

  • Use a priority queue to efficiently select t...read more

PrepInsta
author
2y
#include using namespace std; int main () { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int M = 1 << 20; int dp[M]; char res[M]; for (int i = 1; i < M; i++) dp[i] = INT_MAX...read more
Help your peers!
Add answer anonymously...
Infosys System Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter