Sort by

recency

|

2063 Discussions

|

  • + 0 comments

    Data structures are the backbone of efficient programming—they organize and store data in ways that make problem-solving faster and more effective. betinexchange

  • + 0 comments

    Who wrote this description?! How is this problem even live... idx = (x ^ lastAnswer) % n <- the description is missing the mod operator

  • + 0 comments

    Jesus, this is the most horribly written problem so far. idx calc is wrong, it explains the queries poorly, the return type is wrong for java. Do youself a favor and just screen shot the problem statement and have AI rewrite it to something more comprehensible.

    Terrible way to explain a hash table.

  • + 0 comments

    Wrong problem statement when computing idx, and so its misleading.

  • + 0 comments

    public static List dynamicArray(int n, List> queries) { List lastAnswers = new List();

        int lastAnswer = 0;
        List<List<int>> seqList = new List<List<int>>();
    
        for (int i = 0; i < n; i++){
            seqList.Add(new List<int>());
        }
    
        foreach (var query in queries){
            int index = (query[1]^lastAnswer) % n;
    
            if(query.First() == 1){
                seqList[index].Add(query.Last());
            }
            else{
                int x = query.Last();
                int size = seqList[index].Count;
                lastAnswer = seqList[index][x % size];
                lastAnswers.Add(lastAnswer);
            }
        }
    
        return lastAnswers;   
    }