XOR play
Basic Accuracy: 0.0% Submissions: 3 Points: 1

Given an integer N, list all the divisors of N (excluding N) in sorted order. Find the number formed by performing the XOR operation on each divisor in the list.

Example 1:

Input: N = 10
1 2 5
All the proper divisors are 1, 2 and 5.
1 XOR 2 XOR 5 = 6

Example 2:

Input: N = 8
1 2 4
All the proper divisors are 1, 2 and 4.
1 XOR 2 XOR 4 = 7

Your Task:
You don't need to read or print anything. Your task is to complete the function xor_play() which takes N as input parameter and returns a list of integers containing all the proper divisors in sorted order. The last element in the list must contain the XOR result.

Expected Time Complexity: O(sqrt(N))
Expected Space Complexity: O(K) where K is the number of divisors of N.


1 <= N <= 109

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.