Maximum XOR Suffix

Maximum XOR Suffix

FULLTIME

An array of n integers, arr , is given. Pick any index then calculate the XOR of the array from that index through the highest index. Append the value to the array. Repeat this process zero or more times. Determine the highest value possible.


Function Description

Complete the function maximumValue in the editor below.

maximumValue has the following parameter:

  1. int arr[n] : the starting array


Returns

int : the maximum possible value in the array


Example 1 :


Input: arr = [8, 2, 4, 12, 1]
Output: 14
Explanation: Explantion is shwon in the image above
The max strength possible is 14.


Example 2 :

Input: arr = [1, 2, 3]
Output: 3
Explanation: Regardless of what index is chosen, the XOR value can never be greater than 3


Constraints:

  • 1 ≤ n ≤ 105
  • 0 ≤ arr[i] < 230



  • Get one-to-one training from Google Facebook engineers

    Top-notch Professionals

    Learn from Facebook and Google senior engineers interviewed 100+ candidates.
    Most recent interview questions and system design topics gathered from aonecode alumnus.
    One-to-one online classes. Get feedbacks from real interviewers.

    Customized Private Class

    Already a coding expert? - Advance straight to hard interview topics of your interest.
    New to the ground? - Develop basic coding skills with your own designated mentor.
    Days before interview? - Focus on most important problems in target company question bank.