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.
This is my first time posting a comment here on this site. I'm currently practicing some python to prepare myself for interview questions!
I didn't see any python solutions, for this problem, here on this forum so I figured I'd post what I came up with. If anyone has any questions about how it works, please feel free to ask! :)
Also, any suggestions on how I could have done it better are also appreciated. Cheers
# Python3: Dynamic Array# created by: Andrew ClarkN,Q_size=map(int,input().split(" "))lastAns=0seqList=[]foriinrange(N):seqList.append([])foriinrange(Q_size):q,x,y=map(int,input().strip().split(" "))seq=((x^lastAns)%N)if(q==1):seqList[seq].append(y)else:# q == 2lastAns=seqList[seq][y%len(seqList[seq])]print(lastAns)
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 →
Hi there friends :)
This is my first time posting a comment here on this site. I'm currently practicing some python to prepare myself for interview questions! I didn't see any python solutions, for this problem, here on this forum so I figured I'd post what I came up with. If anyone has any questions about how it works, please feel free to ask! :)
Also, any suggestions on how I could have done it better are also appreciated. Cheers