Maximum Xor with Prefix and Suffix


  • 1
    L

    ###Description

    • We have N numbers as an array, you need to find a prefix array and a suffix array, which we can get the maximum xor value with all elements in them. Notice that for prefix[0, l] and suffix[r, n - 1], do not intersect (l < r), and they can be empty.

    ###Limits

    • -Memory limit per test: 256 megabytes
    • -Time limit per test: The faster the better

    ###Compile & Environment

    • C++
      g++ Main.cc -o Main -fno-asm -Wall -lm --static -std=c++0x -DONLINE_JUDGE Java
    • J2SE 8
      Maximum stack size is 50m

    ###Input

    • The first line is one number N (1 <= N <= 100000)
      The second line contains N numbers ai(0 <= ai <= 1e12) separated by space, which represents the array.

    ###Output

    • Just output the maximum xor result.

    ##Sample Test
    ###Input

    3


    1 2 3

    ###output

    3


  • 0
    R

    [link text](0_1476255929772_xor_exam1.cpp link url)


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.