Skip to content

Conversation

@DataWorshipper
Copy link

Description of Change

This pull request adds a C++ implementation of the Sliding Window XOR problem to the Bit Manipulation section.

The algorithm calculates the bitwise XOR of every window of size k in an array of n integers generated using the recurrence relation:

The array of size n is generated using the recurrence:

arr[0] = x;                 // first element
arr[i] = (a * arr[i-1] + b) % c;  // for i = 1 to n-1

It maintains a sliding window of size k using two pointers, efficiently computing the cumulative XOR of all windows in O(n) time with O(n) space.

The submission is self-contained, with detailed Doxygen documentation and a test() function that includes multiple verified test cases to ensure correctness.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate
  • I acknowledge that all my contributions will be made under the project's license

Notes: Adds an O(n) solution for computing cumulative XOR of sliding windows in arrays of size n using a two-pointer technique. Includes self-test cases and detailed documentation.

@DataWorshipper
Copy link
Author

I need to change some things in the pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant