You are viewing a single comment's thread. Return to all comments →
Here is the C# implementation:
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { uint n = uint.Parse(Console.ReadLine()); uint[] v = Array.ConvertAll(Console.ReadLine().Split(' '), uint.Parse); Stack<uint> s = new Stack<uint>(); long max = 0; for (int i = 0; i < n; i++) { while (s.Any()) { uint c = s.Peek() ^ v[i]; if (c >= max) { max = c; } if (v[i] < s.Peek()) { s.Pop(); } else { break; } } s.Push(v[i]); } Console.WriteLine(max); } }
Seems like cookies are disabled on this browser, please enable them to open this website
AND xor OR
You are viewing a single comment's thread. Return to all comments →
Here is the C# implementation: