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.
tl;dr: do not generate array, search for patterns.
If you want to get the whole array then the answer is... you can't :( It can be up to 10^15 long and it's to much for computer. And even then, every question can be in form 1 10^15 so you would have to spen "10^15 time" on single question and that's definitely too much.
What you should do instead is to look at the properties of the xor, maybe try to write a little bit of both arrays on paper and search for patterns.
Imho it's pretty tough task. I'm by no means like those great coders in top100, but I think I'm getting decent at it and it took me some time to get this problem completely solved. Maybe you should get to the "bit manipulation" problems in algorithms domain first and then come back after few ACs.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Xor-sequence
You are viewing a single comment's thread. Return to all comments →
tl;dr: do not generate array, search for patterns.
If you want to get the whole array then the answer is... you can't :( It can be up to 10^15 long and it's to much for computer. And even then, every question can be in form 1 10^15 so you would have to spen "10^15 time" on single question and that's definitely too much.
What you should do instead is to look at the properties of the xor, maybe try to write a little bit of both arrays on paper and search for patterns.
Imho it's pretty tough task. I'm by no means like those great coders in top100, but I think I'm getting decent at it and it took me some time to get this problem completely solved. Maybe you should get to the "bit manipulation" problems in algorithms domain first and then come back after few ACs.