All Tracks Problem

XOR of Subarray
Tag(s):

Ad-Hoc, Algorithms, Easy-Medium

Problem
Editorial
Analytics

Given an array of $$N $$ elements , You need to find subarray of size $$Z $$ , XOR of whose elements is minimum.If multiple such subarrays exist,Choose the subarray whose starting Index is Maximum. Print the start Index of that subarray.

Input Format:
First line of the input will have $$T $$ (number of test cases). Then for each test case first line will have two integers $$N $$ and $$Z $$. The second line will have a list of $$N$$ space separated integers denoting the Array values (Array is denoted by A).

Output Format: For each test case, output a single integer denoting starting Index of Subarray.

Input Constraints:

$$1 \le T \le100 $$
$$1 \le Z \le N \le10^4$$
$$1 \le A_i \le10^{12} $$

SAMPLE INPUT
1
3 2
1 2 3
SAMPLE OUTPUT
2
Explanation

Cost in shops 1 and 2 : 1 XOR 2 = 3
Cost in shops 2 and 3 : 2 XOR 3 = 1
Since cost from shop 1 to 2 is more than those in shop 2 to 3, Milly should start shopping from shop number 2 itself.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic, Kotlin

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Euromonitor International

Challenge Name

Euromonitor International Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications