My issue
cook your dish here
def find_mex_of_xor(T, test_cases):
results =
for L, R, X in test_cases:
# Create the XOR set S
S = set((L + i) ^ X for i in range(R - L + 1))
# Find the MEX
mex = 0
while mex in S:
mex += 1
results.append(mex)
return results
Input reading
T = int(input()) # Number of test cases
test_cases = [tuple(map(int, input().split())) for _ in range(T)]
Processing
results = find_mex_of_xor(T, test_cases)
Output results
for res in results:
print(res)
what is the problem with this code
task # 2 has runtime error
My code
# cook your dish here
def find_mex_of_xor(T, test_cases):
results = []
for L, R, X in test_cases:
# Create the XOR set S
S = set((L + i) ^ X for i in range(R - L + 1))
# Find the MEX
mex = 0
while mex in S:
mex += 1
results.append(mex)
return results
# Input reading
T = int(input()) # Number of test cases
test_cases = [tuple(map(int, input().split())) for _ in range(T)]
# Processing
results = find_mex_of_xor(T, test_cases)
# Output results
for res in results:
print(res)
Problem Link: MEX of XOR Practice Coding Problem