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.
- Dynamic Array
- Discussions
Dynamic Array
Dynamic Array
Sort by
recency
|
95 Discussions
|
Please Login in order to post a comment
This is my answer matched with a few people and it is alright but does not pass all testy cases. Can someone help
def dynamicArray(n, queries): arr=[[] for _ in range(n)] lastAnswer=0 ans=[] for i in queries: idx=(i[1]^lastAnswer)%n if i[0]==1: arr[idx].append(i[2]) elif i[0]==2: v=i[2]%len(arr[idx]) lastAnswer=arr[idx][v] ans.append(lastAnswer) return(ans)
Java
C#
That is all the helpful information I needed. I appreciate you sharing.
C++ vector dynamicArray(int n, vector> queries) {
}