HTMLify
max-xor-subarray-of-size-k.py
Views: 2 | Author: prakhardoneria
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | class Solution: def maxSubarrayXOR(self, arr, k): n = len(arr) current_xor = 0 for i in range(k): current_xor ^= arr[i] max_xor = current_xor for i in range(k, n): current_xor ^= arr[i - k] current_xor ^= arr[i] if current_xor > max_xor: max_xor = current_xor return max_xor |