Difficulty optimizing XOR SubSequencies problem to get it pastt time out issues in test cases with large data [closed]

This "advanced" XOR Subsequences Puzzle on Hacker Rank computes the Xor sum of each of the contiguous subsequences in a given array. It then determines the frequency that number (xor sum) occurs. If there are multiple numbers having the maximal frequency chose the smallest one. The issue is test cases with a large array containing say, 100,000. These all fail by timing out. Not that the program seems to hang, it's just that have a short time. I've tryed Python3.11 optimizing to O(n) but passing only 9 out of 20 cases. Switched to Haskell Optimized to, I believe, O(log n) but still timed out roughly half the test cases. Can this be resolved by using PyPy 3 or C.

Mar 4, 2025 - 15:41
 0
Difficulty optimizing XOR SubSequencies problem to get it pastt time out issues in test cases with large data [closed]

This "advanced" XOR Subsequences Puzzle on Hacker Rank computes the Xor sum of each of the contiguous subsequences in a given array. It then determines the frequency that number (xor sum) occurs. If there are multiple numbers having the maximal frequency chose the smallest one.

The issue is test cases with a large array containing say, 100,000. These all fail by timing out. Not that the program seems to hang, it's just that have a short time.

I've tryed Python3.11 optimizing to O(n) but passing only 9 out of 20 cases. Switched to Haskell Optimized to, I believe, O(log n) but still timed out roughly half the test cases.

Can this be resolved by using PyPy 3 or C.