Maximum length of the subsequence such that XOR of each consecutive element is equal to k

Правка en1, от abhinavxd, 2020-11-08 21:54:27

Find the maximum length of the subsequence such that XOR of each consecutive element is equal to k. example: [3,2,4,3,5] and k=1. Answer = 3, subsequence = [3,2,3]

And for [1,2,5,7,9,8,5] ans would be 3.

So far I have tried these approaches :

A naive two-loop solution where we will use two loops and find the subsequence with XOR equals to k. 2.Second I am thinking of dynamic programming where I can store XOR of already calculated subsequence but I am not able to complete the algorithm.

Can someone please tell me some other way of solving this problem?

Thanks

Теги #bitmasks, xor subarray

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский abhinavxd 2020-11-08 21:55:13 4 Tiny change: 'ls to k.\n2.Second' -> 'ls to k.\n\n\n2.Second'
en1 Английский abhinavxd 2020-11-08 21:54:27 670 Initial revision (published)