We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Bit Manipulation
  4. XOR Matrix

XOR Matrix

Problem
Submissions
Leaderboard
Discussions
Editorial

Consider a zero-indexed matrix with rows and columns, where each row is filled gradually. Given the first row of the matrix, you can generate the elements in the subsequent rows using the following formula:

Each row is generated one by one, from the second row through the last row. Given the first row of the matrix, find and print the elements of the last row as a single line of space-separated integers.

Note: The operator denotes bitwise XOR.

Input Format

The first line contains two space-separated integers denoting the respective values of (the number of columns in the matrix) and (the number of rows in the matrix).
The second line contains space-separated integers denoting the respective values of the elements in the matrix's first row.

Constraints

Output Format

Print space-separated integers denoting the respective values of the elements in the last row of the matrix.

Sample Input 0

4 2
6 7 1 3

Sample Output 0

1 6 2 5

Explanation 0

We use the formula given above to calculate the values in the last row of the matrix:

We then print each value (in order) as a single line of space-separated integers.

Author

mHuman

Difficulty

Hard

Max Score

50

Submitted By

2977

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website

Join us

Create a HackerRank account

Be part of a 26 million-strong community of developers

Please signup or login in order to view this challenge

or
Already have an account?Log in