You are given an array A of length N and an integer K.
A function F(i,j) is defined below as,
F(i,j) = ai ^ ai+1 ^ ai+2 ^... ^aj .
where ai , ai+1 , .. , aj are elements of array A and 0 <= i <= j < n .
You use the above function F(i,j) for each unique pair (i, j) , where 0 <= i < n and 0 <= j < n and i <= j , and put the results into a new array B.
Your task is to find the Kth largest element of array B.
Note : Assume K is always valid and answer always exists for given K.
Input :
Output :
Constraint :
valid (i,j) are {(0,0),(0,1),(0,2),(1,1),(1,2),(2,2)}
on applying F(i,j) for each (i,j), we get an array B as {4,2,0,6,4,2}.
Therefore , 4th largest element of B is 2.