Google Online Test help

Правка en3, от abc123, 2020-08-23 08:28:51

You are given an array, find the minimum k, such that the count of number of subarrays whose xor is atmost k, is atleast x.

1<=N<=1e5

1<=X<=N*(N+1)/2

Sample Input

4 7

1 2 3 4

Output

4

Subarrays are

{1} {1,2} {1,2,3} {2,3} {2} {3} {4} {1,2,3,4} (count of number of subarrays with xor atmost 4 is 8)

Note: XOR of a subarray is the xor of all the elements in the subarray

I tried binary searching on k, and each time found the count of subarrays with xor less or

equal to k, but that involved trie and heavy implementation, any other simpler approach?

Теги #binary search, #google, #trie

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский abc123 2020-08-23 08:28:51 3
en2 Английский abc123 2020-08-23 08:28:19 19
en1 Английский abc123 2020-08-23 08:27:22 597 Initial revision (published)