Jumpy Humpy
Practice
3 (53 votes)
Data structures
Dynamic programming
Easy
Stacks
Problem
85% Success 11631 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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\)

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
10 votes
Tags:
StacksBasics of StacksSetsData Structures
Points:20
63 votes
Tags:
ArraysData StructuresEasyImplementationQueueStacks
Points:20
175 votes
Tags:
Data StructuresEasyStacks