A Simple Minus

View as PDF

Submit solution

Points: 10
Time limit: 0.05s
Memory limit: 2M

Problem type
Allowed languages

Your computer engineering instructor decided to ramp things up a bit (in terms of difficulty, of course) with this next task:

Write a program to find the maximum difference between the XOR of adjacent elements of a given array.

More formally,

Given an array A, find the maximum value of (A[i] \oplus A[i+1]) - (A[j] \oplus A[j+1]) for some i and j, where i \neq j.

Unimpressed by the supposed "challenge", you open up your favourite text editor and begin typing away... in assembly.

Input Specification

The first line of input will contain a single integer N (3 \le N \le 100).

The second line of input will contain N space-separated integers in the range [-10^3, 10^3], denoting the contents of array A.

Output Specification

The desired integer value as defined by your teacher on a line by itself.

Sample Input

3 2 1

Sample Output



We can find the maximum value when i = 2 and j = 1:

\displaystyle (A[2] \oplus A[3]) - (A[1] \oplus A[2]) = (2 \oplus 1) - (3 \oplus 2) = 2


To use libc in NASM, the first line of your program should be ; libc. For all others, it should be ; features: libc.


  • -1
    _ryan6_  commented on June 21, 2022, 1:29 p.m.

    Are you serious bro? Is this "easy"? I can't even understand the words in the question :C