(defparameter testCases (read))

(defparameter N NIL)

(defparameter *array* '())

(defparameter results '())

(dotimes (x testCases)

(setf N (read))

(setq result 0)

(dotimes (i N)

(setf *array* (cons (read) *array*)))

(dolist (a *array*)

(dolist (b *array*)

(setf result (logxor result (+ a b)))))

(setf *array* '())

(setf results (cons result results)))

(dolist (result results)

(format t “~a~%” result))

Above is my solution to XOR problem in LISP but during submission it says time out. Please help!

Can you explain me ur approach ?? Cuz I don’t know LISP and understanding your code might take more time to me…

Hence it’s better if u can explain me ur approach…

Simple approach to this problem is multiplying each number by two and XOR all of them

Which is O(n) approach…

For example if test cases were.

1 2 5

Then answer would be

(1+1)\oplus(2+2)\oplus(5+5)

== 2\oplus4\oplus10

Have a look at my c++ soln if u want then HERE

HERE is the editorial…doing what was asksd in question… i.e nested for loops will give tle… Do let me know if u still have doubt…