Substring Xor
Practice
4.2 (15 votes)
Binary search
Data structures
Medium
Tries
Problem
60% Success 2470 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Given a length-n array a and a number k, there are \(\frac{n \times (n + 1)}{2}\) subarrays in total. For each subarray, we can compute the xor sum of its elements.
In this problem, we will sort all these xor-sums in non-increasing order. And we want to find the \(k^{th}\) element.
\(\textbf{Input}\)
The first line contains two numbers n (\(1 \le n \le 100 000\)) and k (\(1 \le k \le \frac{n \times(n + 1)}{2}\)).
The second line contains n numbers - \(a_1, a_2, a_3, \dots , a_n\) (\(0 \le a_i < 2^{20}\)).
\(\textbf{Output}\)
Output the \(k^{th}\) element in the non-increasing order.
Submissions
Please login to view your submissions
Similar Problems
Points:30
30 votes
Tags:
Advanced Data StructuresData StructuresMediumTries
Points:30
10 votes
Tags:
TrieAdvanced Data StructuresData Structures
Points:30
17 votes
Tags:
Data StructuresMediumTries
Editorial