Humpy likes to jump from one building to another. But he only jumps to next higher building and stops when no higher building is available. Stamina required for a journey is xor of all the heights on which humpy jumps until he stops.
If heights are [1 2 4], and he starts from 1, goes to 2 stamina required is \(1 \oplus 2 = 3\), then from 2 to 3. Stamina for the entire journey is \(1 \oplus 2 \oplus 4 = 7\). Find the maximum stamina required if can start his journey from any building.
Input
First line: $$N$$, no of buildings.
Second line: $$N$$ integers, defining heights of buildings.
Output
Single Integer that is the maximum stamina required for any journey.
Constraints
\(1 \le N \le 10^5\)
\(1 \le Heights \le 10^9\)
If he starts from building 1, the stamina required is 1 ^ 2 ^ 3 ^ 8 = 8
From the building 2, the stamina required is 2 ^ 3 ^ 8 = 9
From the building 3, the stamina required is 3 ^ 8 = 11
Similarly, from 8 and 6, stamina required are 8 and 6 respectively.
The maximum stamina required for the journey is from building 3 is 11.
So the answer is 11.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor