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.
So here's a link to the actual problem on hacker-rank: https://www.hackerrank.com/challenges/dynamic-array/problem?isFullScreen=true
It's basically a question about computing queries on a 2 dimensional array. The specific problem is that it tells you how to compute idx wrong:
It says:
Compute idx = (x XOR lastAnswer)
But that seems to be wrong, because if you compute idx that way it results in an index error even if you do everything correctly. On their own sample desk checking and explanation, they also don't compute idx that way.
The way they actually compute it is (you can check Query 3 and Query 4 at the end):
idx = (x XOR lastAnswer) % n
I'm convinced they got this part wrong in the problem description. But I'm here to learn so I may be the one who either didn't understand the question correctly or I'm missing something. That's why I thought to just ask the community.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Dynamic Array
You are viewing a single comment's thread. Return to all comments →
So here's a link to the actual problem on hacker-rank: https://www.hackerrank.com/challenges/dynamic-array/problem?isFullScreen=true It's basically a question about computing queries on a 2 dimensional array. The specific problem is that it tells you how to compute idx wrong: It says: Compute idx = (x XOR lastAnswer) But that seems to be wrong, because if you compute idx that way it results in an index error even if you do everything correctly. On their own sample desk checking and explanation, they also don't compute idx that way. The way they actually compute it is (you can check Query 3 and Query 4 at the end): idx = (x XOR lastAnswer) % n I'm convinced they got this part wrong in the problem description. But I'm here to learn so I may be the one who either didn't understand the question correctly or I'm missing something. That's why I thought to just ask the community.