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.
- Prepare
- Data Structures
- Arrays
- Dynamic Array
- Discussions
Dynamic Array
Dynamic Array
Sort by
recency
|
2059 Discussions
|
Please Login in order to post a comment
public static List dynamicArray(int n, List> queries) { List lastAnswers = new List();
this problem is so confusing to read
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.
what is the takeaway in this question? Does it have some hidden logic that helps in solving other problems?
Admin or @ikbalkazar, please correct the problem description.
In query 1 and query 2:
from:
idx = (x ^ lastAnswer)
to:
idx = (x ^ lastAnswer) % n